tb / ng2-nouislider

Angular2 noUiSlider directive
http://tb.github.io/ng2-nouislider/
MIT License
184 stars 114 forks source link

Formatter does not work together with ngModel #191

Open bjolletz opened 6 years ago

bjolletz commented 6 years ago

Hi!

Thanks for providing this component!

I have a problem with using a formatter together with ngModel. As far as I understand, when using a formatter you are supposed to provide 'formatted' values for ngModel. Because if I don't, then the sliders will not begin at the correct positions. However, when changing the sliders, 'unformatted' values are assigned back to the ngModel property.

For instance, if I begin with something like

model = ['#1', '#2']; // Formatted values

[(ngModel)]="model",
[format]="someFormatter"

...and provide a formatter that maps back and forth between numbers and strings, then after dragging the slider, the value of the model property will be an (unformatted) array of numbers instead of the expected array of (formatted) strings.

This might be related to #50 . Is this something you're aware of? I could probably provide an example project, but will not bother if you're already aware of this issue.