programing

각도, 한계값 대상 및 $index별 추적

jooyons 2023. 3. 21. 21:54
반응형

각도, 한계값 대상 및 $index별 추적

필터링을 통해 들어오는 개체를 제한하려고 하는데(모든 개체를 표시하는 옵션이 있기 때문에), 제한 대상 및 인덱스로 추적하려고 하면 문제가 발생합니다.코드는 다음과 같습니다.

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

앵글 에러에 속았다고 쓰여있어서 $index에 의한 트랙이 여기서 작동하지 않는 것 같아요.제대로 된 방법을 못 찾겠어요 도움이 필요해요감사합니다!

필터, 예를 들어limitTo,orderBy등...앞에 와야 한다track by어레이 소스에 적용되기 때문에track by표현.

<div ng-repeat="item in filter.values | limitTo:filterLimit track by $index">

이 사용법을 시험해 보다limitTo전에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">

언급URL : https://stackoverflow.com/questions/30201046/angular-limitto-and-track-by-index

반응형