angular-selectize icon indicating copy to clipboard operation
angular-selectize copied to clipboard

Can we store both the text and value field in the ng-model ?

Open CarbonFactory opened this issue 10 years ago • 8 comments

I need to use the select input's selected item's text for validation. So, I can use this either by storing both text/value in the ng-model or get the text of the select input via api call or something like getText()

CarbonFactory avatar Mar 14 '15 14:03 CarbonFactory

+1 Need ability to have model set as multi-keyed object

miketeix avatar Mar 19 '15 14:03 miketeix

Actually, I think ngModel should hold the options objects, as it does in the AngularJS select directive (and in angular-chosen-localytics). Currently, it only holds the selected values, so when the options are objects, we have to find back which ones are selected.

Problem: that would be a breaking change. So this capability would have to be activated by an option.

PhiLhoSoft avatar Apr 29 '15 10:04 PhiLhoSoft

Is there a workaround to this, very similar if not the same as what I'm asking here :

http://stackoverflow.com/questions/32911621/angular-selectize-bind-to-model-not-value

AntonRand avatar Oct 02 '15 23:10 AntonRand

The workaround is as I wrote: you have a list of options, ngModel provides the value(s) (key(s)), you search the item in the list with this key (these keys). It is quite trivial with Lodash or similar, and generally fast enough.

PhiLhoSoft avatar Oct 03 '15 06:10 PhiLhoSoft

Thank you Philippe. I was originally using the ui-select plugin which did this out of the box without needing a workaround.

It's too slow when I have ~1500 options, not a problem with angular-selectize though.

AntonRand avatar Oct 03 '15 15:10 AntonRand

+1

wallawe avatar Apr 28 '16 16:04 wallawe

+1 Really missing this feature. There's many use cases when you'd like to store the whole object and not a single property value. Like @PhiLhoSoft it should be added as an option.

danielcardoso5 avatar Jun 22 '16 09:06 danielcardoso5

any news on this?

delcasda avatar Nov 14 '17 16:11 delcasda