gpt4 book ai didi

Angularjs:ng-options group by

转载 作者:行者123 更新时间:2023-12-03 10:36:17 28 4
gpt4 key购买 nike

我有这个一级树的情况:

<select ng-model="tipost" 
ng-options="tip.DESC group by tip.TIPIS for tip in tipall"><br>
</select>

json在哪里:
[
{"ID":"1", "IDPARENT":"0", "TIPIS":"", "DESC":"GroupName1"},
{"ID":"2", "IDPARENT":"1", "TIPIS":"GroupName1", "DESC":"CHILDNAME1"},
{"ID":"3", "IDPARENT":"0", "TIPIS":"", "DESC":"GroupName2"}
]

问题是这会与他们的 child 一起创建 optgroups 但重复
根源也是:
- GroupName1
- GroupName2
[ GroupName1 ]
- CHILDNAME1
[ GroupName2 ]

我想生产:
[ GroupName1 ]
- CHILDNAME1
[ GroupName2 ]

最佳答案

如果您将 json 更改为这样的内容,则分组不太像这样:

[
{"ID":"1", "TIPIS":"GroupName1", "DESC":"name"},
{"ID":"2", "TIPIS":"GroupName1", "DESC":"name1"},
{"ID":"3", "TIPIS":"GroupName2", "DESC":"name2"},
{"ID":"4", "TIPIS":"GroupName1", "DESC":"name3"},
]

然后你会得到你想要的分组方式

jsFiddle: http://jsfiddle.net/rtCP3/182/

关于Angularjs:ng-options group by,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18615624/

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