[英]dynamic variable ng-repeat inside ng-repeat
我在其他ng-repeat指令中有ng-repeat。 我正在尝试使用第一个中的键使第二个ng-repeat动态化,但是此语法不起作用。 有办法使它起作用吗? 也许有不同的表示法?
<div class="entry" ng-repeat="(key, choice) in choices">
<div >
<div ng-repeat="option in fields['user_' + key].options | filter : {v:choices[key].junior.v}" class="box-content-value">{{option.l}}</div>
</div>
</div>
过滤器的工作没有问题,因为它是一个对象, fields.user_$
另一方面, fields.user_$
不是,我必须组合字符串+变量使其起作用。
注释选择中的请求无关紧要,只是js对象的简单数组
另一方面,字段看起来像这样
"fields": {
"user_0": {
"display": true,
"options": [{
"k": 0,
"v": "",
"l": "Please select"
}, {
"k": 1,
"v": "male",
"l": "Male"
}, {
"k": 2,
"v": "female",
"l": "Female"
}],
"read_only": false
}
}
所以我必须显示仅具有fields.option.v
属性的fields.options.l
完整值。 那就是为什么我在这里使用过滤器。
使用$index
代替key
:
<div class="entry" ng-repeat="choice in choices">
<div >
<div ng-repeat="option in fields['user_' + $index].options | filter : {v:choice.junior.v}" class="box-content-value">{{option.l}}</div>
</div>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.