我还是新的AngularJS,所以我只是想做一个简单的CRUD应用程序。目前,我使用控制器MyCtrl1处理的div中的$ http数据(在JSON文件中)。
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>
orderBy过滤器根据所选字段进行排序; startFrom将数组切成在某点开始; limitTo根据预设页面大小过滤。没有分页过滤器的性能是非常可怕的,但我想知道是否有另一种方法去做这个?
我有Chrome的Batarang,在性能选项卡下,它显示ngRepeatWatch占用了最多的时间,我认为它与所有的过滤我做的。
{{ expression | filter1 | filter2 }}
只是使用
<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>
Angular 2使用pipes,但它看起来像过滤器:
<div>The chained hero's birthday is
<p>{{ birthday | date:'fullDate' | uppercase}}</p>
<div>