I want to create a range slider with an input field to directly type the value (like in jQM: http://demos.jquerymobile.com/1.4.4/slider/).
My directive looks like this:
app.directive("mySlider", [function () {
return {
restrict: "E",
replace: true,
scope: {
id: "@?",
min: "@",
max: "@",
step: "@?",
value: "=ngModel"
},
template: "" +
"<div class='my-sliderWrap'>" +
"<input type='number' min={{min}} max={{max}} step={{step}} value={{value}} ng-model=value>" +
"<input type='range' min={{min}} max={{max}} step={{step}} value={{value}} ng-model=value>" +
"</div>",
link: function ($scope, $element, $attrs) {
//some logic here
}
}
}]);
Well, this works nice when I'm changing the value of the number input. The slider moves and the value attributes both are updated. As soon as I move the slider directly, both value attributes still update but the text of my number input gets cleared somehow and set to its minimum.
Have I made some mistake within the template or with the data binding?