amitava82 / angular-multiselect

[NOT MAINTAINED]Native AngularJS multiselect directive
http://amitava82.github.io/angular-multiselect
MIT License
140 stars 124 forks source link

Show only one property but select complete object #92

Open Mojo90 opened 7 years ago

Mojo90 commented 7 years ago

If I have the following Object:

{
    id:1,
    name: 'Audi'
}

It is possible via options="c.name for c in cars" to show the name but if I select it I need the complete Object selected as maybe some objects have the same Name I need to get the ID of the Object. How can that be achieved? (Sorry could not read out of the examples and other issues.)

Alternatively I can Imagine to show more than one property as text but how could that achieved? Already tried sth like options="c.id, c.name for c in cars" but without success. If that is easily possible to achieve it is a great plugin even after years of creating the code base  😎!!

NithinBiliya commented 7 years ago

It is possible to get the 'id' of the selected object assigned to the model as - options="c.id as c.name for c in cars" But this will not work as expected if 'id' is a string. Then the 'id' of the selected value will be displayed as the button text.

Mojo90 commented 7 years ago

Okay it is not so a big problem at the moment that if it is selected than only the ID appears (you are right my IDs are strings). But than is it possible to generate the displayed button text as Audi (1), so something like options="c.id as 'c.name (c.id)' for c in cars"? I tried that and unfortunately it does not work like that it does than print out c.name (c.id) everytime.