简体   繁体   中英

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 :

[{ 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 ?
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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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