我将以下 json 结构存储在 resultData 中:
{
"ParentObjects": [
{
"objId": "A1",
"ChildObjects": [
{
"description": "child object1"
},
{
"description": "child object2"
}
]
},
{
"objId": "A2",
"ChildObjects": [
{
"description": "child object3"
},
{
"description": "child object4"
},
{
"description": "child object5"
}
]
},
{
"objId": "A3",
"ChildObjects": [
{
"description": "child object6"
},
{
"description": "child object7"
}
]
}
]
}
我的 html 中有 2 个 ng-repeat,如下所示:
<table>
<tbody ng-repeat="parentObj in resultData">
<tr ng-repeat="childObj in parentObj.ChildObjects">
<td>{{childObj.description}}</td>
</tr>
</tbody>
</table>
我想将显示的
是否可以考虑/计算所有子对象来限制行?
最佳答案
你可以在ng-repeat中使用limitTo进行限制
<table>
<tbody ng-repeat="parentObj in resultData | limitTo:4">
<tr ng-repeat="childObj in parentObj.ChildObjects ">
<td>{{childObj.description}}</td>
</tr>
</tbody>
</table>
关于javascript - Angular JS 嵌套 ngRepeat 循环如何在 maxRows 超过限制后中断?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38101376/