You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Assume all atributes are interpolated (min and max) and bound (using ng-model) on the input[range].
If the range's max is over 100 (eg. 200), and the value is set over 100, the range's value will be "stuck" at 100 (the default max value for a range). When the range's max attribute is updated, the range's value stays at 100, while in the model the value is still 200.
I worked around on this, by using a $timeout.
The text was updated successfully, but these errors were encountered:
input[type="range"] is not a supported type in Angular (e.g. see #5892), so (when using ngModel on it) it falls back to input[type="text"]. This can lead to all sorts of weird behaviors.
Among other things, the min and max attributes are not watched by Angular for changes, so there will be no re-rendering once they change from {{vm.max}} to 200 for example.
Basically, here is what is going on:
Initially, the element's max and min properties are set to {{vm.max}}/{{vm.min}} respectively.
Since these are invalid values, the actual limits fall back to the default: 0 - 100
ngModelController applies the modelValue (200) to the input. Since the max allowed value is currently 100, the input's value is set to 100.
Interpollation kicks in asynchronously and sets max/min to 200/0 respectively.
The browser updates the input's limits in the UI.
Since there has been no change in the modelValue or the viewValue, ngModelController doesn't "understand" it has to re-$render() (so it doesn't). As a result, the input's viewValue remains at 100 (and the modelValue remains at 200).
This is a problem for input[type="range"], because (unlike all other input types) its "display value" (what the user sees, i.e. the position of the knob) may change even if it's actual value hasn't changed.
Basically, you need to let ngModelController know, that max/min/ngMax/ngMin needs to be watched over and when the corresponding attribute value changes, it needs to re-$render().
Fiddle here: https://jsfiddle.net/dserrano_lnk/fy93ptkk/
Assume all atributes are interpolated (min and max) and bound (using ng-model) on the input[range].
If the range's max is over 100 (eg. 200), and the value is set over 100, the range's value will be "stuck" at 100 (the default max value for a range). When the range's max attribute is updated, the range's value stays at 100, while in the model the value is still 200.
I worked around on this, by using a $timeout.
The text was updated successfully, but these errors were encountered: