angularjs - Generate key value pair using ng-options -
i have data below
"data": [ { "id":"1", "name":"first" }, { "id":"2", "name":"second" }, { "id":"3", "name":"third" } ]
i want generate list like
<select> <option value="1">first</option> <option value="2">second</option> <option value="3">third</option> </select>
i used ng-options, not able desired output.
see fiddle:
<select name="myselect" ng-model="selectedoption" ng-options="option.id option.name option in options"> <option value="">choose option</option> </select>
if need, can remove default choose option option, , set selectedoption
value in ["1", "2", "3"]
preselect default option.
Comments
Post a Comment