简体   繁体   English

无法让ng-options处理我的数据

[英]Having trouble getting ng-options to work with my data

I have created a quick plunker with what I am trying to do. 我用自己想做的事创造了一个快速的傻瓜。

What I am trying to achieve is, when a user clicks on one of the two items in list, the main header of each will be added to the menu bar. 我想要实现的是,当用户单击列表中的两个项目之一时,每个项目的主标题都将添加到菜单栏中。

For Example, the main header of Central Pulse, is New Zealand. 例如,Central Pulse的主要标头是新西兰。

http://plnkr.co/edit/5WSLCrssOGrf7XbV6TvX http://plnkr.co/edit/5WSLCrssOGrf7XbV6TvX

This is my select that I use: 这是我使用的选择:

<select ng-model="selectBox" ng-options="dataV.name for dataV in data"></select>

I have also tried, 'dataV as dataV.name for dataV in data' 我也尝试过,“ dataV作为dataV.data中dataV的名称”

And my object contains: 我的对象包含:

{"name":type,"children":[]}

Since data is an object and not an array, the correct syntax for ng-options is one of the following : 由于data是对象而不是数组,因此ng-options的正确语法是以下之一:

label for (key , value) in object
select as label for (key , value) in object
label group by group for (key, value) in object
select as label group by group for (key, value) in object

For example, you can use : 例如,您可以使用:

ng-options="dataV as dataV.name for (dataKey,dataV) in data"

See also here for more details 另请参阅此处以了解更多详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM