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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -