angularjs ng-options 不起作用 [英] angularjs ng-options not working
本文介绍了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.
这篇关于angularjs ng-options 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文