角,limitTo和跟踪由$指数 [英] Angular, limitTo and track by $index
问题描述
我试图限制对象在未来通过过滤(因为会有显示所有最终的选项),但是我对指数试图limitTo和轨道时遇到了问题。这里是code:
I am trying to limit an object coming in by filtering (because there will be an option to show all eventually), however I am running into issues when trying to limitTo and track by index. Here is the code :
<div ng-repeat="item in filter.values track by $index | limitTo:filterLimit" class="cengage-builder-result-filter-value" value="item" update-filter="updateFilter">
在控制器:
$scope.filterLimit = 5;
它说我有角度误差受骗者所以我用$指数的思维轨迹不在这里工作。似乎无法找到一个妥善的办法做到这一点,可以使用一些帮助。谢谢!
It's saying I have dupes in the angular error so I'm thinking the track by $index isn't working here. Can't seem to find a proper way to do this, could use some help. Thanks!
推荐答案
过滤器,例如 limitTo
,排序依据
,等等......必须由来之前的轨道,因为它们应用到阵列源,而不是对
轨道由
前pression。
Filters, like limitTo
, orderBy
, etc... must come before track by
, since they apply to the array source, rather than to the track by
expression.
<div ng-repeat="item in filter.values | limitTo:filterLimit track by $index">
这篇关于角,limitTo和跟踪由$指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!