-
Notifications
You must be signed in to change notification settings - Fork 123
Can't set initial value #95
Comments
Same issue here, I created a Stack Overflow ticket, so if anyone has this issue as well can find a solution once presented |
+1 |
1 similar comment
+1 |
Best solution for this is to set the initial value in a containing object. ie.
|
I seem to have half of this problem. |
I had a dig into the code and noticed that the Slider for Bootstrap (bootstrap-slider.js) uses the attribute "value" to set its initial values. See here for examples. Then in the angular-bootstrap-slider (slider.js) which this sits on, passes in two attributes "ngModel" and "value". The initSlider() function then does some decision making and messes around with the ngModel value incorrectly I believe. I found that if I ignore the "ngModel" and just rely on the "value" attribute I could default the initial value of the slider.
So in my case above (from my directive containing the slider) you can see I have set the directives ngModel the both the sliders ng-model (which I don't care about anymore) and also the value (which seems to work). ng-model is required by angular-bootstrap-slider so I had to provide it but it doesn't seem to hurt setting the value to the same attribute. |
Angular binding via ng-model only works one way. If I move the slider, my scope variable is changed accordingly. The binding from the UI to the script works. However, if I change the value of the scope variable, the slider does not change.
In fact, I am unable to set an initial value per the doc in the "slider" directive. e.g. value="7". I did find that if data-slider-value="7" does work to set the initial value. It does not, however, make the Angular binding work.
The text was updated successfully, but these errors were encountered: