对大型数据集多重过滤NG-重复 [英] ng-repeat with multiple filters on large data set
问题描述
我还是新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..
推荐答案
只要使用
<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屋!