AngularJS - ngOptions前pressions [英] AngularJS - ngOptions expressions

查看:155
本文介绍了AngularJS - ngOptions前pressions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图访​​问对象的列表作为ngOptions使用选择元素中。不管我怎么努力,我不能让列表来填充选择。如果我在渲染页面的选项前pression,数据显示细腻,似乎有正确的结构。所以我知道它不是一个错字或东西在我的前pression。我可以访问数据。例如:

I am trying to access a list of objects to use as ngOptions inside a Select element. No matter what I try, I cannot get the list to populate the Select. If I render the options expression in the page, the data displays fine and seems to have the correct structure. So I know its not a typo or something in my expression. I CAN access the data. Eg:

{{ form_event.providers.search_terms[form_event.type.toLowerCase()] }}

[{"group": "program", "name": "title"},
 {"group": "program", "name": "aspect_ratio"},
 {"group": "episode", "name": "aspect_ratio"},
 {"group": "episode", "name": "house_id"}]

所以,给出的数据结构,这是我认为它可以在NG-选项来完成,但它不工作:

So, given the data structure, this is how I think it could be done in ng-options, but it doesn't work:

<select ng-options="term.name group by term.group for term in
    form_event.providers.search_terms[form_event.type.toLowerCase()]">
</select

下面是一个小提琴: http://jsfiddle.net/9B3zN/1/

任何线索将是巨大的。

推荐答案

当你使用 NG-选项不要忘了添加 NG-模型属性选择否则将无法正常工作

Whenever you use ng-options do not forget to add ng-model attribute to select otherwise it would not work

<select ng-model="selected" ng-options="term.name group by term.group for term in form_event.providers[form_event.type.toLowerCase()]">
    <option value="">-- choose --</option>
</select>

更新小提琴: http://jsfiddle.net/9B3zN/2​​/

这篇关于AngularJS - ngOptions前pressions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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