Here is what seems to be bothering a lot of people (including me).
When using the ng-options
directive in AngularJS to fill in the options for a &
$scope.items = [{name: 'a', age: 20},{ name: 'b', age: 30},{ name: 'c', age: 40}];
Case-1) label for value in array:
selected item is : {{selectedItem}}
age of selected item is : {{selectedItem.age}}
Output Explanation (Assume 1st item selected):
selectedItem = {name: 'a', age: 20} // [by default, selected item is equal to the value item]
selectedItem.age = 20
Case-2) select as label for value in array:
selected item is : {{selectedItem}}
Output Explanation (Assume 1st item selected): selectedItem = 20 // [select part is item.age]