Description
I'm trying to switch between two sliders - first is with default precision (0) and step (1), second has precision: 1
and step: 0.1
. The default value of model for second slider is 0.4
.
While switching from first slider definition to second, everything updates fine, only the default value of model is rounded with precision of the first slider. For 0.4
, it rounds it to 0
.
I've found out that the watch expression of rzSliderModel
is evaluated before the new options - rzSliderOptions
and the function thrLow
updates the value of model to 0
.
Is there a way to force options to be updated before the slider value?
It can be simply fixed like this:
this.scope.$watch('rzSliderModel', function(newValue, oldValue) {
if (newValue === oldValue)
return;
self.applyOptions(); // added applyOptions()
thrLow();
});
But it is probably not the best way. It calls applyOptions
on every model change.
Any ideas to make it better?