2014-03-04 73 views
0

angularJS中orderBy元素选项的子项不起作用。 我想按“pos”子女排序。在NG-重复感谢AngularJS orderBy小孩不工作

$scope.commands = { 
"xyz" : { 
"group":"g2", 
"pos":2 
}, 
"abc" : { 
"group":"g2", 
"pos":3 
}, 
"ijk" : { 
"group":"g1", 
"pos":1 
} 
}; 

<div ng-repeat="(key, data) in commands | orderBy:'data.pos'">{{data.pos}} - {{key}}</div> 
+0

'orderby'仅适用于数组:看起来像这样:http://docs.angularjs.org/api/ng/filter/orderBy – akonsu

回答

1

过滤器将只在阵列,而不是在对象上工作,你必须写自定义过滤器和排序。

我会尝试创建一个并共享。

+0

检查了解更多信息:http://justinklemm.com/angularjs-filter-排序对象 - ngrepeat / – koolunix