I am using $interval
for my custom stopwatch. Within the $interval
function I have a variable $scope.inputValue
which is binded to a range. The problem is that after each iteration of $interval
(every 500ms), the most recent $scope.inputValue is not taken into account, but only the value at the initialization (1000).
How to solve this?
Controller
.controller('DashCtrl', function($scope, $interval) {
var interval, incrementTimer;
$scope.inputValue = 1000;
//
//
incrementTimer = function() {
userValue = $scope.inputValue;
console.log(userValue); // does not update when range changes
};
//
// button toggle
$scope.toggleTimer = function() {
interval = $interval(incrementTimer, 500);
};
})
HTML
<input type="range" min="0" max="2000" step="100" ng-model="inputValue">
<button class="button button-positive" ng-click="toggleTimer()">Start</button>