I'm pretty new to angularJS,
I have a range input, which might get it's value updated via code. I have created a ng-model for this input, and have ng-binded it to a <p> tag.
It works fine as long as the range input is modified by the user, but when it is updated by the code, the updated value is not getting reflected.
I have a created a fiddle: https://jsfiddle.net/cj1emb1r/16/
How can I make it work?
<div ng-app=''>
<input type='range' min='20' max='200' ng-model="amount" id='slider'>
<p ng-bind="amount"> </p>
<button onclick='foo();'> Run!</button>
</div>
The function where the value is modified:
<script>
var flag = true;
function foo() {
var sliderObj = document.getElementById('slider');
var value = parseInt(sliderObj.value);
if(value >= 200 || value <= 0) {
flag = !flag;
}
if(flag) {
sliderObj.value = value + 5;
}
else {
sliderObj.value = value - 5;
}
console.log(value);
setTimeout("foo()", 200);
}
</script>`