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.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
ng-model does not set initial value and position of input[type=range] #6726
Basically, a range input is set up with an initial value using ng-model. The actual value of the HTML element, and the position of the range slider, are incorrect. I would expect the slider position and html input value to be in sync with the model variable.
Verified on chrome and firefox running on Windows 8.
I see there are other issues opened for input[type=range], its not clear they are related.
Reacted by Rory O’Kane, Dave Clayton, Javier Cejudo, Peter Hurst, Jonny Arnold, John Parker, Steven Chambers, Mayhew Park, Felix Schul, Uli Fahrer and 7 more
It seems I found the problem.
Angular sets value before setting min, max and step so it seems that the range is in the wrong position. To solve the problem I used this directive
With GitHub’s new Reactions feature, you no longer need to comment “+1”. Instead, you can mark your interest by clicking the “+:smile:” at the top-right of the first comment in this issue, then choosing :+1: (“+1”). This avoids sending a useless notification to everyone subscribed to this issue.
Reacted by Berkay Sargın, Carlos Anjos, George Kalpakas, Charles Labas, Martin Ma, Terra, Jeff Brown, Steven Chambers, Uli Fahrer, Cortland Klein and 5 more
Reacted by George Kalpakas, Jonny Arnold, Hans Löfgren, Stanislav Karakovskii and alphaVariable
Activity
IgorMinar commentedon Mar 17, 2014
This is still an issue with Angular 1.2.14: http://jsfiddle.net/HVp2J/7/
fschwiet commentedon Mar 17, 2014
As a work-around, one can set the model value within a $timeout handler.
Rajat-Chowdhary commentedon Mar 18, 2014
$timeout doesn' help, the issue remains.
@fschwiet : http://jsfiddle.net/HVp2J/9/
fschwiet commentedon Mar 18, 2014
@Rajat-Chowdhary Sorry, I should have included a code sample showing how $timeout can work as work-around: http://jsfiddle.net/fschwiet/YC4av/
The workaround does feel dicey since the model value cannot be initialized until the $timeout callback for the workaround to work.
ardf69 commentedon Apr 24, 2014
It seems I found the problem.
Angular sets value before setting min, max and step so it seems that the range is in the wrong position. To solve the problem I used this directive
ardf69 commentedon Jun 23, 2014
Here there is the new version of ngRange without private scope:
zavidovych commentedon Dec 3, 2014
this is still an issue, right?
http://plnkr.co/edit/MAT5KPkXyWblAJ71L8nK?p=preview
17 remaining items
davedx commentedon Mar 1, 2016
Another lazy workaround hack:
cue232s commentedon Mar 14, 2016
+1
roryokane commentedon Mar 14, 2016
With GitHub’s new Reactions feature, you no longer need to comment “+1”. Instead, you can mark your interest by clicking the “+:smile:” at the top-right of the first comment in this issue, then choosing :+1: (“+1”). This avoids sending a useless notification to everyone subscribed to this issue.
nagarajumusini commentedon Mar 18, 2016
I have solved my problem using ondrag method by removing ng-model.
check this http://codepen.io/nagarajumusini/pen/BKpGJz
marianmazarovici commentedon Apr 13, 2016
+1
felixschul commentedon May 18, 2016
+1
Jerome2606 commentedon May 22, 2016
Adding ng-init to input works for me to set initial value
Found solution in:
http://jsfiddle.net/jestho/8dymV/7/
Narretz commentedon Jul 5, 2016
We are working on this (finally). Closing as a duplicate of #5892
jacobbullock95 commentedon Jul 6, 2016
$(document).ready(function () {
angular.element('.yourclasshere').val(valueoftheslideronload);
});
this jQuery workaround works so you can set a value when the page loads but whatever ithe value of the slider controls wont sync until it's touched.
mrdulin commentedon Aug 3, 2016
@davedx Maybe this is the best way before the issue is solved.
AhmadRedha commentedon Oct 1, 2016
<input type="range" min="15" data-ng-init="signup.age=30" value="30" max="85" step="1" name="ageInput" class="form-control input-lg" ng-model="signup.age" oninput="ageOutputId.value = ageInput.value" /> <output name="ageOutputName" id="ageOutputId">30</output>