Angular ng-repeat中的orderBy数组项值

Angular ng-repeat中的orderBy数组项值,第1张

Angular ng-repeat中的orderBy数组项值 从1.3.0-rc.5开始

从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)



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5476639.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存