Below is my code snippet
<body ng-app='abc' ng-controller='MainCtrl as ctrl'>
<div ng-repeat="note in ctrl.notes">
<span class="label"> {{note[1]}}</span>
<span class="label"> {{note.label}}</span>
<span class="status" ng-bind="note.done"></span>
</div>
</body>
and my notes object contains
self.notes = [
{ id : 1 , label : 'First Note' , done : false, [1]:3, 'string key':4 },
{ id : 2 , label : 'Second Note' , done : false, 1:2, 'string key':4 },
{ id : 3 , label : 'Done Note' , done : true, 1:2,'string key':4 },
{ id : 4 , label : 'Last Note' , done : false, 1:2 , 'string key':4}
];
I am able to access the label with a.label
and a['label']
, may I know why these two ways? The second a['label']
only is enough right?
And also if you observe in my notes object, one of the key in first row is [1]
, I am able to access it with note[1]
in html, please let me know how come it is possible?