我正在尝试使用嵌套的ng-repeat来渲染结构。
我的对象结构如下
outercollection: [
{
....
....
innercollection: [
// number of objects here is variable. It can be 0 as well.
{},
{}
]
....
},
{
....
....
innercollection: [
{},
{}
]
....
}
]
现在我需要渲染内部集合并将其限制为2。
我需要一些类似于嵌套的东西,内部循环应该完全针对几个条目执行。
forEach(collection in outerCollection) {
foreach(entry in collection.innerCollection) {
If(count ==2)
break;
// do something and increment the count
}
}
答案 0 :(得分:1)
<div ng-repeat="o in outercollection">
<div ng-repeat="innercollection in o|limitTo:2"></div>
</div>