我需要根据值对 ng-repeat
中的 $scope
对象进行排序。我可以通过自定义过滤器将其转换为数组来实现排序,但键或值只能推送到数组中。我需要键和值才能在 UI 中显示它:
$scope.list = {
test:58uy43: "test:one",
test:24ht76: "test:two",
test:26df90: "test:three",
test:39fg67: "test:four",
test:18ds65: "test:five"
}
<div ng-repeat="(key,value) in list">{{key}} : {{value}}</div>
请帮我解决这个问题
最佳答案
...ng-repeat="数据中的o | 过滤器:过滤器| orderBy:sortPredicate:sortReverse"...
其中“filter”是您要搜索的值(过滤器),“sortPredicate”是您要排序的列名称,“sortReverse”是指示记录顺序的 bool 值。
关于javascript - 使用过滤器对 ng-repeat 中的 $scope 对象进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34903253/