diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-18 10:14:46 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-18 10:14:46 +0200 |
commit | 4fe70c8f1bd032183990de37d19cdd9faafba0da (patch) | |
tree | 889e373be4e320281da8c05776908e1f5df434c7 /js/build/app.js | |
parent | 66abbda5576ed5f675c645584969fc3e09152164 (diff) |
correctly destroy element when route is being changed
Diffstat (limited to 'js/build/app.js')
-rw-r--r-- | js/build/app.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/js/build/app.js b/js/build/app.js index fbd3d7e7e..ad93b6f43 100644 --- a/js/build/app.js +++ b/js/build/app.js @@ -2211,19 +2211,24 @@ app.directive('newsTimeout', ["$timeout", "$rootScope", function ($timeout, $roo 'newsTimeout': '&' }, link: function (scope, element) { + var destroyed = false; var seconds = 7; var timer = $timeout(scope.newsTimeout, seconds * 1000); // remove timeout if element is being removed by // for instance clicking on the x button - scope.$on('$destroy', function () { + element.on('$destroy', function () { $timeout.cancel(timer); }); // also delete the entry if undo is ignored and the url // is changed $rootScope.$on('$locationChangeStart', function () { - element.remove(); + if (!destroyed) { + destroyed = true; + element.remove(); + scope.newsTimeout(); + } }); } }; |