不工作angularjs NG选项 [英] angularjs ng-options not working

查看:147
本文介绍了不工作angularjs NG选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图与AngularJS一个简单的选择下拉列表

I try to make a simple select dropdown with AngularJS

这是我的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​​)是这种形式:

[{"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选项指令。

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选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆