Skip to main content
 首页 » 编程设计

javascript之在 AngularJs 的 ng-options 中使用 orderBy

2025年05月04日101jiqing9006

我确实有以下形式的对象:

item = {key1: {count: x}} where x is an integer 

我想使用计数对模板中的选项进行排序。 我通过以下方式使用 ng-options:

data-ng-options="key1 for (key1, sub_item) in item | orderBy: 'sub_item.count'" 

不幸的是,排序不起作用。知道我怎么能做到这一点吗?

请您参考如下方法:

根据docs您必须在引号中设置 orderBy 值:

orderBy: 'sub_item.count'