单个元素上的多个NG-重复 [英] Multiple ng-repeat on single element
本文介绍了单个元素上的多个NG-重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Is this possible to achieve a code like this:-
<tr ng-repeat="data in dataArray,value in valueArray">
{{data}} {{value}}
</tr>...??
I m having two arrays i want to show them in single row.
PS: - 我不是要求syntax.I我想找的逻辑来实现这一目标
谢谢
PS:- I m not asking for syntax.I m looking for logic to achieve this Thanks
如: - http://jsfiddle.net/6ob5bkcx/1/
推荐答案
您应该在控制器中这样做,不是在视图中。映射dataValues成键/值对的对象,并引用使用索引值数组。这假定每个数据键具有相应的值项。
You should be doing this in the controller, not in the view. Map the dataValues into a key/value pair object and reference the values array using an index. This assumes that each data key has a corresponding value key.
控制器:
var dataArray = [];
var valueArray = [];
this.repeatData = dataArray.map(function(value, index) {
return {
data: value,
value: valueArray[index]
}
});
查看:
<tr ng-repeat="data in repeatData">
{{data.data}} {{data.value}}
</tr>
这篇关于单个元素上的多个NG-重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文