I am writing my own countdown timer ticker in Angular.js as a service. The value shows up in the element correctly, but it is not counting down. Not sure what I am doing wrong since I have the $interval(function(){ }, 1000); in the service to cause a digest() and make it tick.
angular.module('monitorApp')
.factory('countDown', function($interval) {
$interval(function(){ }, 1000);
return {
countDownTicker: function(secondsLeft) {
secondsLeft = Math.round(secondsLeft/1000);
return --secondsLeft;
}
}
});
Controller:
$scope.countDownTicker = countDown.countDownTicker(result.broadcastStamp);
HTML:
<span class="info-test">{{ countDownTicker }}</span>
UPDATE: New service...still not working:
angular.module('monitorApp')
.factory('countDown', function($interval) {
$interval(function(){ }, 1000);
return {
countDownTicker: function(secondsLeft) {
return $interval(function(secondsLeft){
secondsLeft = Math.round(secondsLeft/1000);
--secondsLeft;
}, 1000);
}
}
});