对大型数据集多重过滤NG-重复 [英] ng-repeat with multiple filters on large data set

查看:107
本文介绍了对大型数据集多重过滤NG-重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还是新AngularJS,所以我只是试图做一个简单的CRUD应用程序。目前,我拉与 $ HTTP 中的数据(在一个JSON文件)在 DIV 由控制器处理 MyCtrl1

I'm still new to AngularJS, so I'm just trying to do a simple CRUD app. Currently I pull the data (in a JSON file) with $http in a div handled by a controller MyCtrl1.

function MyCtrl1($scope, $http) {
    $http.get('data/accounts.json').success(function(data) {
        $scope.accounts = data;
    ...
    }); 
}

这里面 DIV 具有以下 TBODY

<tbody>
    <tr ng-repeat="account in accounts | orderBy:sort.field:sort.desc | startFrom:currentPage * pageSize | limitTo:pageSize">
        <td contentEditable="true" ng-repeat="(label, value) in account" ng-show="fields[label].visible">{{value}}</td>
    </tr>
</tbody>

根据所选字段的排序依据过滤器种类; startFrom 切片阵列开始在某一点; limitTo 根据preset的页面大小的过滤器。如果没有分页过滤性能是pretty可怕的,但我不知道是否有去这个问题的另一种方式?

The orderBy filter sorts according to a selected field; startFrom slices the array to start at a certain point; limitTo filters according to a preset page size. Without the pagination filters the performance was pretty terrible, but I was wonder if there was an alternative way to go about this?

我Batarang为​​Chrome和性能选项卡这表明 ngRepeatWatch 占用了大部分时间之下,我认为它与我做的所有过滤办..

I have Batarang for Chrome and under the Performance tab it showed ngRepeatWatch taking up the most time, and I reckon it has to do with all the filtering I'm doing..

推荐答案

{{EX pression |过滤器1 |过滤器2}}

只要使用

<tr ng-repeat="account in accounts | filter1 | filter2 | filter3" >
  <td contentEditable="true" ng-repeat="(label, value) in account" ng-show="fields[label].visible">{{value}}</td>
</tr>

这篇关于对大型数据集多重过滤NG-重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆