gpt4 book ai didi

angularjs - 如何将 ng-select group by 用于 bool 值,以及订单和标签?

转载 作者:行者123 更新时间:2023-12-03 08:22:10 26 4
gpt4 key购买 nike

我有一些数据:

0: {id: 1, name: "hhh", description: "hhh", isPopular: false,…}
1: {id: 2, name: "bbb", description: "bbb", isPopular: true,…}
2: {id: 3, name: "ccc", description: "ccc", isPopular: false,…}
3: {id: 4, name: "ddd", description: "ddd", isPopular: true,…}
4: {id: 5, name: "aaa", description: "aaa", isPopular: false,…}
5: {id: 6, name: "ggg", description: "ggg", isPopular: false,…}

我想出现在 ng-select 中:

Popular
bbb
ccc
The rest
aaa
ccc
ggg
hhh

所以我用过

<select ng-selected="true"
ng-options="category.name group by category.isPopular for category in ctrl.categories |
orderBy: ['-isPopular','name']"
ng-model="myModel.category">
</select>

然而这是返回:

aaa
ccc
ggg
hhh
true
bbb
ccc

如何标记组并按组排序?

最佳答案

group by需要传入组名。例如:

<select ng-selected="true"
ng-options="category.name group by category.isPopular ? 'Popular' : 'The rest' for category in ctrl.categories |
orderBy: ['-isPopular','name']"
ng-model="myModel.category">
</select>

关于angularjs - 如何将 ng-select group by 用于 bool 值,以及订单和标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31341870/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com