I have a jQuery based slider that updates an input box. The angular handle for the input box's content is not getting updated when slider moves though the value is updated (as shown in image)
Code:
<form ng-app="myApp" ng-controller="myController" ng-submit="readData()" >
<input type="text" id="amount" value="3-7" ng-model="duration" ng-init="duration='3-7'" >
<button type="submit" value="Submit">Submit</button>
</form>
<div id="slider-range">
<script>
$(function() {
$( "#slider-range" ).slider({
range: true,
min: 0,
max: 15,
values: [ 3, 7 ],
slide: function( event, ui ) {
$( "#amount" ).val( ui.values[ 0 ] + " - " + ui.values[ 1 ] );
}
});
});
</script>
</div>
<script type="text/javascript" >
var app = angular.module('myApp', []);
app.controller('myController', function ($scope, $http, $templateCache, $interval, $timeout) {
$scope.readData = function () {
alert($scope.duration); // always show the init value i.e. 3-7
};
});
</script>
Picture
Edit 1: To investigate further, I am posting the whole code.
<html>
<head lang="en">
<meta charset="UTF-8">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script type="text/javascript" src="js/angular.js"></script>
<title></title>
</head>
<body >
<form ng-app="myApp" ng-controller="myController" ng-submit="readData()" >
<input type="text" id="amount" value="3-7" ng-model="duration" ng-init="duration='3-7'" >
<button type="submit" value="Submit">Submit</button>
</form>
<div id="slider-range">
<script>
</script>
</div>
<script type="text/javascript" >
var app = angular.module('myApp', []);
app.controller('myController', function ($scope, $http, $templateCache, $interval, $timeout) {
$scope.readData = function () {
alert($scope.duration);
};
});
$(function() {
$( "#slider-range" ).slider({
range: true,
min: 0,
max: 15,
values: [ 3, 7 ],
slide: function( event, ui ) {
$( "#amount" ).val( ui.values[ 0 ] + " - " + ui.values[ 1 ] );
}
});
});
</script>
</body>