Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
383 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...