使用ng-options中的orderBy进行排序

时间:2013-05-22 13:12:26

标签: angularjs angularjs-orderby ng-options

我的代码是:

<select ng-model="i.br" ng-options="item.name as info[item.name] for item in e.br | orderBy:info[item.name]" class="combobox">

这里orderBy没有根据info [item.name]进行排序。

e.br is an array like :
0:object (object is name:'abc')
1:object (object is name:'xyz')
..
.
.
.

and info is a hash like :
{
'abc' : '123abc'
'xyz' : '456xyz'
}

任何可能的方式我想显示123abc并根据这些排序但保持模型的值为abc

1 个答案:

答案 0 :(得分:0)

无法在Javascript中对哈希进行排序,因此您需要将info哈希值转换为数组。