Angularjs 如何使用带有顺序和标签的ng select group by作为布尔值?

Angularjs 如何使用带有顺序和标签的ng select group by作为布尔值?,angularjs,ng-options,angularjs-select,Angularjs,Ng Options,Angularjs Select,我有一些数据: 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", isPopul

我有一些数据:

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中显示为:

受欢迎
bbb
ccc
其余的
aaa
ccc
ggg

所以我用了

<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
正确
bbb
ccc


如何按组标记组和订单?

我很确定,如果要分组,您应该使用以下选项:

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


groupBy
在中,因此您必须正确使用语法。

您需要将组名传递给
groupBy
。例如:

<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>


您是否尝试过类似于
。。。按类别分组。是否流行Popular':“其余的”…
?@rob你应该回答这个问题,这样以后其他人就可以更容易地找到它。如果你这样做,我就投赞成票!行。不确定这是否真的有效Angular没有groupBy筛选器Angular筛选器有。。。但我知道他现在用的不是这个。