javascript - Angular, limitTo and track by $index - Stack Overflow

I am trying to limit an object coming in by filtering (because there will be an option to show all even

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

In the controller:

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

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

In the controller:

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

Share Improve this question asked May 12, 2015 at 20:43 ajmajmajmaajmajmajma 14.2k25 gold badges83 silver badges137 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 76

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

Try this Use limitTo before track by

 <div ng-repeat="item in filter.values | limitTo:filterLimit track by $index" class="cengage-builder-result-filter-value" value="item" update-filter="updateFilter">

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1737271441a3929723.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信