简体   繁体   English

角度:多选下拉菜单

[英]Angular : Multiselect dropdown

I'm using this library to create multiselect dropdown. 我正在使用此来创建多选下拉列表。 everything's fine . 一切安好 。
but there is something i can't handle it . 但是有些事情我无法处理。
in source file there is displayProp: 'label' ,it means in json you should have a field call label , like this : 在源文件中有displayProp: 'label' ,这意味着在json中您应该有一个字段调用label ,如下所示:

[{ id: 1, label: "David" }, { id: 2, label: "Jhon" }, { id: 3, aaa: "Danny" }];

here's my problem : 这是我的问题:
if i have database without label field, i have to change displayProp: 'label' , but what if i have 2 multi select dropdown in my form from 2 jason with differnt field ? 如果我有没有标签字段的数据库,则必须更改displayProp: 'label' ,但是如果我的表单中有2个具有不同字段的jason有2个multi select下拉菜单,该怎么办?
Thx 谢谢

According to the documentation , you can have multiple selects using different labels quite easily. 根据文档 ,您可以很容易地使用不同的标签进行多个选择。 Just use extra-settings attribute when creating a particular select and specify displayProp just for that one select. 在创建特定选择并仅针对该选择指定displayProp时,只需使用extra-settings属性即可。

I have personally had problems with this library and finally used angular-multi-select instead but I also ran into the problem with the label for the multi-select. 我个人对此库有问题,最终还是使用了角度多重选择,但是我也遇到了多重选择标签的问题。

I would suggest looking at this library but you will still need a custom controller, service or factory (depending on what you are doing and the code conventions in place) to mutate whatever you have in your database into the label you need for your multi-select and also something in place to handle the ticked properties of every object in the list which would essentially be a for loop and an if-statement. 我建议您看一下这个库,但是您仍然需要一个自定义的控制器,服务或工厂(取决于您正在执行的操作和所采用的代码约定),以将数据库中的所有内容突变为您需要的标签, select和适当的东西来处理列表中每个对象的已标记属性,本质上是for循环和if语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM