【问题标题】:Sorting using orderBy in ng-options在 ng-options 中使用 orderBy 进行排序
【发布时间】:2013-05-22 13:12:25
【问题描述】:

我的代码是:

<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 的任何可能方式

【问题讨论】:

  • 请提供更多细节或 plunker demo 问题的语言有点混乱
  • 是的,感谢您的 -1。不知道为什么人们会滥用这个不赞成投票的东西......我编辑了这个问题

标签: angularjs angularjs-orderby ng-options


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-08
    • 2016-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多