gpt4 book ai didi

javascript - 嵌套 ngRepeat limitTo 不起作用

转载 作者:行者123 更新时间:2023-11-28 01:02:09 24 4
gpt4 key购买 nike

我目前遇到 ng-repeat 问题,并限制了 View 中显示的元素数量。我想知道这是否与嵌套循环有关。这是代码:

<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>

我尝试通过执行 limitTo:1 来限制列表项,效果很好。仅当试图限制后分割时。感谢您的帮助。

编辑:

此代码有效:

<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>

这是数据对象:

preSplitPrompts data object

最佳答案

试试这个:

ng-class="{$first ? 'panelBackground' : 'altPanelBackground'}"

关于javascript - 嵌套 ngRepeat limitTo 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25490398/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com