2014-03-04 38 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