有没有办法用AngularJS做一个覆盖多个数组的ng-repeat? [英] Is there a way I can do a ng-repeat that covers more than one array with AngularJS?

查看:80
本文介绍了有没有办法用AngularJS做一个覆盖多个数组的ng-repeat?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下内容遍历xa并显示qs.a.text值:

I have the following that loops through xa and prints the qs.a.text values:

<div data-ng-repeat="a in xa">
   <div data-ng-bind-html="a.text"></div>
</div>

<div data-ng-repeat="b in xb">
   <div data-ng-bind-html="b.text"></div>
</div>

有没有办法将这些东西结合起来?

Is there a way that I could combine these something like this:

<div data-ng-repeat="a in xa and xb">
   <div data-ng-bind-html="a.text"></div>
   <div data-ng-bind-html="b.text"></div>
</div>

请注意,xa和xb是始终包含完全相同数量的元素的数组.

Note that xa and xb are arrays that always contain exactly the same number of elements.

推荐答案

当然,您可以使用javascript的concat()连接数组,然后将结果用于重复.

Sure, you can use javascript's concat() to concatenate the arrays and then use the results for your repeat.

因此:

<div data-ng-repeat="item in combined = xa.concat(xb)">
   <div data-ng-bind-html="item.text"></div>
</div>

这篇关于有没有办法用AngularJS做一个覆盖多个数组的ng-repeat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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