The selected value will still correspond to the value in a key-value pair, but this time it will be an object.
$scope.cars = { car01 : {brand : “Ford”, model : “Mustang”, color : “red”}, car02 : {brand : “Fiat”, model : “500”, color : “white”}, car03 : {brand : “Volvo”, model : “XC90”, color : “black”} }; |
The options in the dropdown list do not have to be the key in a key-value pair; they can also be the value or a property of the value object.
<select ng-model=”selectedCar” ng-options=”y.brand for (x, y) in cars”> </select> |