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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -