angularjs ng-options 不起作用

angularjs ng-options 不起作用

问题描述:

我尝试使用 AngularJS 制作一个简单的下拉菜单

I try to make a simple select dropdown with AngularJS

这是我的代码:

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

create_options_array(item.values) 是这种形式:

[{"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?

我相信您缺少 ngModel 指令,并且您正在以不正确的方式调用 ng-options 指令.

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

我在 这里制作了 plunker,它可以在其中发挥作用.

I made plunker here where it would work.