Angularjs ng-options not working

I am trying to make a simple selection of a dropdown using AngularJS

this is my code:

<select class="span3" novalidate="" data-ng-options="select p.name for p in create_options_array(item.values)"> </select> 

create_options_array(item.values) has the form:

 [{"id":0,"name":"OG"},{"id":1,"name":"OS"},{"id":2,"name":"PG"},{"id":3,"name":"PS"}] 

a drop-down menu appears, but there is no value on it to select what am I doing wrong?

+7
javascript angularjs
source share
1 answer

I believe that you are missing the ngModel directive and you are calling the ng-options directive in the wrong way.

I made a plunker here where it will work.

+25
source share

All Articles