[英]View the size of a filtered ngRepeat array before filtering again with limitTo
我目前正在通過自定義startAtIndex
過濾器和limitTo
過濾器的組合對ngRepeat
進行分頁。 無論頁面如何,我都希望在數據集中顯示結果總數。 但是,當您使用limitTo
,這顯然會在該時間點切斷數組,並且您將無法獲得所需的length屬性。
我的ngRepeat
:
ng-repeat-start="colleague in pagination.filteredData = (colleagueDataArray | filter:{name: queries.name} | filter:{client: queries.client} | filter:queries.generalQuery | orderBy:sortByField:reverseSort | startFrom: pagination.startAtIndex | limitTo:pagination.pageSize)">
我將過濾器的結果分配給pagination.filteredData
對象,然后可以使用{{pagination.filteredData.length}}
在控制器中的任何位置顯示其長度。
我如何解決這個問題,以獲取由startAtIndex
和limitBy
過濾后的過濾數組的長度? 我可以或多或少地地過濾colleagueDataArray
數組,然后過濾生成filteredArray
與再次ngRepeat
?
如果這對您沒有意義,請告訴我,以便我編輯問題。
編寫一個自定義過濾器,無論您在此嘗試什么。
ng-repeat="data in bigData | filter:myfilter"
$scope.myfilter= function(data)
{
// Check length or i dont know
// $scope.bigData.length
if($scope.bigData.length > 2)
{
return true; // this will be listed in the results
}
return false; // otherwise it won't be within the results
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.