summaryrefslogtreecommitdiffstats
path: root/js/directive/NewsTimeout.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/directive/NewsTimeout.js')
-rw-r--r--js/directive/NewsTimeout.js9
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