@@ -43,6 +43,7 @@ angular.module('mgcrea.ngStrap.scrollspy', ['mgcrea.ngStrap.helpers.debounce', '
4343 var $scrollspy = { } ;
4444
4545 // Private vars
46+ var unbindViewContentLoaded , unbindIncludeContentLoaded ;
4647 var trackedElements = $scrollspy . $trackedElements = [ ] ;
4748 var sortedElements = [ ] ;
4849 var activeTarget ;
@@ -65,8 +66,8 @@ angular.module('mgcrea.ngStrap.scrollspy', ['mgcrea.ngStrap.helpers.debounce', '
6566 scrollEl . on ( 'scroll' , throttledCheckPosition ) ;
6667
6768 debouncedCheckOffsets = debounce ( this . checkOffsets , options . debounce ) ;
68- $rootScope . $on ( '$viewContentLoaded' , debouncedCheckOffsets ) ;
69- $rootScope . $on ( '$includeContentLoaded' , debouncedCheckOffsets ) ;
69+ unbindViewContentLoaded = $rootScope . $on ( '$viewContentLoaded' , debouncedCheckOffsets ) ;
70+ unbindIncludeContentLoaded = $rootScope . $on ( '$includeContentLoaded' , debouncedCheckOffsets ) ;
7071 debouncedCheckOffsets ( ) ;
7172
7273 // Register spy for reuse
@@ -88,8 +89,8 @@ angular.module('mgcrea.ngStrap.scrollspy', ['mgcrea.ngStrap.helpers.debounce', '
8889 scrollEl . off ( 'click' , this . checkPositionWithEventLoop ) ;
8990 windowEl . off ( 'resize' , debouncedCheckPosition ) ;
9091 scrollEl . off ( 'scroll' , debouncedCheckPosition ) ;
91- $rootScope . $off ( '$viewContentLoaded' , debouncedCheckOffsets ) ;
92- $rootScope . $off ( '$includeContentLoaded' , debouncedCheckOffsets ) ;
92+ unbindViewContentLoaded ( ) ;
93+ unbindIncludeContentLoaded ( ) ;
9394
9495 } ;
9596
0 commit comments