diff --git a/src/growlDirective.js b/src/growlDirective.js index 6a40ed3..a984155 100644 --- a/src/growlDirective.js +++ b/src/growlDirective.js @@ -11,8 +11,8 @@ angular.module("angular-growl").directive("growl", [ inline: '=', limitMessages: '=' }, - controller: ['$scope', '$timeout', 'growl', 'growlMessages', - function ($scope, $timeout, growl, growlMessages) { + controller: ['$scope', '$interval', 'growl', 'growlMessages', + function ($scope, $interval, growl, growlMessages) { $scope.referenceId = $scope.reference || 0; growlMessages.initDirective($scope.referenceId, $scope.limitMessages); @@ -30,7 +30,7 @@ angular.module("angular-growl").directive("growl", [ $scope.stopTimeoutClose = function (message) { if (!message.clickToClose) { angular.forEach(message.promises, function (promise) { - $timeout.cancel(promise); + $interval.cancel(promise); }); if (message.close) { growlMessages.deleteMessage(message); diff --git a/src/growlMessageService.js b/src/growlMessageService.js index 7689adc..b53c5db 100644 --- a/src/growlMessageService.js +++ b/src/growlMessageService.js @@ -1,4 +1,4 @@ -angular.module("angular-growl").service("growlMessages", ['$sce', '$timeout', function ($sce, $timeout) { +angular.module("angular-growl").service("growlMessages", ['$sce', '$interval', function ($sce, $interval) { "use strict"; this.directives = {}; @@ -102,7 +102,7 @@ angular.module("angular-growl").service("growlMessages", ['$sce', '$timeout', fu message.countdownFunction = function () { if (message.countdown > 1) { message.countdown--; - message.promises.push($timeout(message.countdownFunction, 1000)); + message.promises.push($interval(message.countdownFunction, 1000, 1)); } else { message.countdown--; } @@ -130,10 +130,10 @@ angular.module("angular-growl").service("growlMessages", ['$sce', '$timeout', fu if (message.ttl && message.ttl !== -1) { //adds message timeout to promises and starts messages countdown function. - message.promises.push($timeout(angular.bind(this, function () { + message.promises.push($interval(angular.bind(this, function () { this.deleteMessage(message); - }), message.ttl)); - message.promises.push($timeout(message.countdownFunction, 1000)); + }), message.ttl, 1)); + message.promises.push($interval(message.countdownFunction, 1000, 1)); } return message;