Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs ng-options not working

I try to make a simple select dropdown with 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) is in this form:

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

the select dropdown appears but it does not have any value on it to select, what I'm doing wrong?

like image 908
maki Avatar asked Aug 06 '13 07:08

maki


1 Answers

I believe you are missing an ngModel directive and you are invoking the ng-options directive in an incorrect way.

I made plunker here where it would work.

like image 154
Florian Avatar answered Nov 07 '22 13:11

Florian