[英]Nested ngRepeat limitTo not working
I'm currently having a problem with ng-repeat and limiting the amount of elements being displayed in my view. 我目前在ng-repeat上遇到问题,并限制了在我的视图中显示的元素数量。 I'm wondering if it has to do with being a nested loop.
我想知道它是否与嵌套循环有关。 Here is the code:
这是代码:
<li style="cursor:pointer; margin:8px;" class="span3" ng-repeat="psp in preSplitPrompts" ng-click="selectRelatedSplitPanels($index)">
<div ng-class="$first ? 'panelBackground' : 'altPanelBackground'" class="thumbnail splitPanel">
<h3>{{ (psp.promptname) ? psp.promptname : "No Name From API" }}</h3>
<hr>
<h2 ng-repeat="postsplit in psp.postSplit | limitTo: 1">{{ postsplit.metrics.preSplitTotalCount ? postsplit.metrics.preSplitTotalCount : 0 }}</h2>
<p>Visits</p>
</div>
</li>
I've tried limiting the list item by doing limitTo:1 and that works fine. 我已经尝试通过执行limitTo:1来限制列表项,并且效果很好。 It's only when trying to limit the postsplit.
仅在尝试限制后拆分时。 Thanks for the help.
谢谢您的帮助。
EDIT:
编辑:
This code works: 此代码有效:
<li style="cursor:pointer; margin:8px;" class="span3" ng-repeat="psp in preSplitPrompts | limitTo: 1" ng-click="selectRelatedSplitPanels($index)">
<div ng-class="$first ? 'panelBackground' : 'altPanelBackground'" class="thumbnail splitPanel">
<h3>{{ (psp.promptname) ? psp.promptname : "No Name From API" }}</h3>
<hr>
<h2 ng-repeat="postsplit in psp.postSplit">{{ postsplit.metrics.preSplitTotalCount ? postsplit.metrics.preSplitTotalCount : 0 }}</h2>
<p>Visits</p>
</div>
</li>
Here is the data object: 这是数据对象:
尝试这个:
ng-class="{$first ? 'panelBackground' : 'altPanelBackground'}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.