How to access javascript object resource with special character in property name

I want to access a property of a JavaScript object with a special character. former my object (data)

{
 no :1 , gender : male , Handedness; : RightHanded
}

      

By doing

console.log(dataHandedness;);

      

Script throws an error. How can I access the property Handedness;

?

Also for rendering this property is angular with

{{ data.Handedness;}}

gives null

+3


source to share


1 answer


AngularJS doesn't do anything special here. Refer to the usual rules for property references in a javascript object.

In the controller: console.log($scope.data['Handedness;'])



In view: {{ data['Handedness;'] }}

+1


source







All Articles