簡體   English   中英

在使用limitTo再次過濾之前,請查看已過濾的ngRepeat數組的大小。

[英]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}}在控制器中的任何位置顯示其長度。

我如何解決這個問題,以獲取由startAtIndexlimitBy過濾后的過濾數組的長度? 我可以或多或少地地過濾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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM