I have an object as below. I have to display this as a drop-down:
var list = [{id:4,name:"abc"},{id:600,name:"def"},{id:200,name:"xyz"}]
In my controller I have a variable that carries a value. This value decided which of the above three items in the array will be selected by default in the drop-down:
$scope.object.setDefault = 600;
When I create a drop-down form item as below:
<select ng-model="object.setDefault" ng-options="r.name for r in list">
I face two problems:
the list is generated as
<option value="0">abc</option> <option value="1">def</option> <option value="2">xyz</option>
instead of
<option value="4">abc</option> <option value="600">def</option> <option value="200">xyz</option>
No option gets selected by default even though i have
ng-model="object.setDefault"