AngularJS:toArray orderBy不使用ng-repeat on key,value pair

时间:2015-09-04 15:07:39

标签: javascript json angularjs angularjs-ng-repeat

div正在被正确重复而没有错误,但它们不是基于值的顺序。我最终希望通过按钮或复选框按最大值和最小值来订购div的功能,但我被困在这里。非常感谢任何帮助,谢谢!

这是我的ng-repeat:

<div ng-repeat="(key, value) in frequency track by $index | toArray | orderBy:'value' ">
</div>

这是我的数据:

$scope.frequency = [1: 138, 2: 147, 3: 144, 4: 144, 5: 148, 6: 140, 7: 145, 8: 176, 9: 142, 10: 136, 11: 164, 12: 146, 13: 146, 14: 133, 15: 163, 16: 158, 17: 157, 18: 133, 19: 156, 20: 149, 21: 148, 22: 149, 23: 149, 24: 144, 25: 161, 26: 142, 27: 166, 28: 144, 29: 137, 30: 154, 31: 172, 32: 138, 33: 128, 34: 143, 35: 160, 36: 152, 37: 136, 38: 140, 39: 145, 40: 150, 41: 143, 42: 147, 43: 157, 44: 160, 45: 150, 46: 135, 47: 137, 48: 136, 49: 135, 50: 173, 51: 137, 52: 162, 53: 182, 54: 154, 55: 171, 56: 123, 57: 161, 58: 127, 59: 129];

我正在使用以下地址找到的toArray过滤器:https://github.com/petebacondarwin/angular-toArrayFilter/blob/master/toArrayFilter.js

1 个答案:

答案 0 :(得分:1)

至于所需的阵列过滤器object,您需要更正下面的对象。

$scope.frequency = {1: 138, 2: 147, ....};