-
-
Notifications
You must be signed in to change notification settings - Fork 902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compareWith does not work with bindValue #535
Comments
@tomasz-nowakowski-stx I am not sure if it makes sense to use
items = [{ id: 7, name: 'Vilnius' }] Eg.: if you have your value as string Having this in mind, solution for your case would be casting string to number before setting the model. |
@varnastadeus The problem is that I never know if values from API are strings or numbers (don't blame me 😃). And inconsistency you mentioned is fine for me in this case. |
Hi guys! I'm the one of developers who, as @varnastadeus said, faced with the same problem. ng-select is really good plugin, but if someone wants to embed it into big project it leads to big problems because of strict comparison('==='). I don't ask you guys to change just compareWith behavior, but maybe you can help by the other way!? As a result for now you're losing a big percent of developers that want to use your product because as I said implementing ng-select into big project takes a lot of time and necessity to write some additional middleware because of ng-select that's not good in my opinion |
Expected behavior
When I use both
compareWith
andbindValue
I would expect thatcompareWith
will still used for comparing.Actual behavior
Run this with console opened.
https://stackblitz.com/edit/angular-d1cvpv?file=src/app/hello.component.ts
Nothing shows up in console. But if you remove
bindValue
the "test" fromcompareFn
should appear in console two times.Why would I need this
Because my initial ngModel is always a string but values in items might be strings or numbers. I want to convert ngModel and values to sting before comparing them in
compareWith
More Info
ng-select version: 1.4.1
browser: all
reproducible in demo page: NO
The text was updated successfully, but these errors were encountered: