$scope.items = [{
id: 1,
label: 'aLabel',
subItem: { name: 'aSubItem' }
}, {
id: 2,
label: 'bLabel',
subItem: { name: 'bSubItem' }
}];
based on above list, below is what I normally use:
<select ng-options="item in items" ng-model="selected"></select>
Very straightforward, as in, I can access the value by using item.xxx
But what is the syntax below:
<select ng-options="item as item.label for item in items" ng-model="selected"></select>
I am totally blur, the as
and for
keyword is for what purpose? I could not really find the doc that explain this, please help.
PS:
Original syntax is <select ng-options="item as item.label for item in items track by item.id" ng-model="selected"></select>
but I removed track by
, because I understand that by reading from the doc.