从AngularJS
1.3.0-rc.5开始,如果未提供其他参数,则
orderBy过滤器(请参阅文档)将使用其项目自动对数组进行排序。
<li ng-repeat="item in items | orderBy">{{item}}</li>
[JS Bin](http://jsbin.com/okatur/59/edit)1.3.0-rc.5之前
所述
orderBy过滤器(见历史文档)还可以采取一个函数作为第二个参数,其返回值为将使用进行比较
<,
=和
>*** 作者。为此,您可以简单地使用
angular.identity(请参阅文档):
$scope.identity = angular.identity;<li ng-repeat="item in items | orderBy:identity">{{item}}</li>
[JS Bin](http://jsbin.com/okatur/6/edit)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)