diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-15 15:26:19 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-15 15:26:19 +0200 |
commit | ce118f2a97d49d218afed33ef7029ce09b95c044 (patch) | |
tree | 8785f7f3d293593b03709adba1e0872c205b7c78 /js/directive | |
parent | 6d617ba3731d3fa8d59be0ab3ad4d85e95c28aec (diff) |
also remove undo entry if user changes the route
Diffstat (limited to 'js/directive')
-rw-r--r-- | js/directive/NewsTimeout.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/js/directive/NewsTimeout.js b/js/directive/NewsTimeout.js index 37458a61b..2d88f4363 100644 --- a/js/directive/NewsTimeout.js +++ b/js/directive/NewsTimeout.js @@ -7,7 +7,7 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsTimeout', function ($timeout) { +app.directive('newsTimeout', function ($timeout, $rootScope) { 'use strict'; return { @@ -15,7 +15,7 @@ app.directive('newsTimeout', function ($timeout) { scope: { 'newsTimeout': '&' }, - link: function (scope) { + link: function (scope, element) { var seconds = 7; var timer = $timeout(scope.newsTimeout, seconds * 1000); @@ -24,6 +24,11 @@ app.directive('newsTimeout', function ($timeout) { scope.$on('$destroy', function () { $timeout.cancel(timer); }); + + // route change also triggers the timeout + $rootScope.$on('$locationChangeStart', function () { + element.remove(); + }); } }; });
\ No newline at end of file |