diff options
Diffstat (limited to 'js/directive/NewsTimeout.js')
-rw-r--r-- | js/directive/NewsTimeout.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/js/directive/NewsTimeout.js b/js/directive/NewsTimeout.js index 0a224778f..9ac2ce47b 100644 --- a/js/directive/NewsTimeout.js +++ b/js/directive/NewsTimeout.js @@ -22,7 +22,8 @@ app.directive('newsTimeout', function ($timeout, $rootScope) { // remove timeout if element is being removed by // for instance clicking on the x button - element.on('$destroy', function () { + scope.$on('$destroy', function () { + destroyed = true; $timeout.cancel(timer); }); @@ -32,6 +33,8 @@ app.directive('newsTimeout', function ($timeout, $rootScope) { // $locationChangeStart triggers twice because of the trailing // slash on the link which is kinda a hack to reload the route // if you click on the link when the route is the same + $timeout.cancel(timer); + if (!destroyed) { destroyed = true; element.remove(); |