简体   繁体   English

在使用limitTo再次过滤之前,请查看已过滤的ngRepeat数组的大小。

[英]View the size of a filtered ngRepeat array before filtering again with limitTo

I'm currently paginating my ngRepeat through a combination of a custom startAtIndex filter and a limitTo filter. 我目前正在通过自定义startAtIndex过滤器和limitTo过滤器的组合对ngRepeat进行分页。 I want to display the total number of results in the data set regardless of the page. 无论页面如何,我都希望在数据集中显示结果总数。 However, when you use limitTo , this obviously chops the array off at that point, and you can't get the length property you want. 但是,当您使用limitTo ,这显然会在该时间点切断数组,并且您将无法获得所需的length属性。

My ngRepeat : 我的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)">

I assign the results of the filter to the pagination.filteredData object, I can then display it's length anywhere in my controller with {{pagination.filteredData.length}} . 我将过滤器的结果分配给pagination.filteredData对象,然后可以使用{{pagination.filteredData.length}}在控制器中的任何位置显示其长度。

How can I go about this to get the length of the filtered array before it's filtered by startAtIndex and limitBy ? 我如何解决这个问题,以获取由startAtIndexlimitBy过滤后的过滤数组的长度? Can I somehow partially filter the colleagueDataArray array, and then filter the resulting filteredArray again with the ngRepeat ? 我可以或多或少地地过滤colleagueDataArray数组,然后过滤生成filteredArray与再次ngRepeat

If this makes no sense to you, please let me know so I can edit the question. 如果这对您没有意义,请告诉我,以便我编辑问题。

Write a custom filter, whatever you are trying there. 编写一个自定义过滤器,无论您在此尝试什么。

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