@@ -42,7 +42,7 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
42
42
var DIRECTION_NONE = 'none' ;
43
43
44
44
var stateChangeCounter = 0 ;
45
- var lastStateId , nextViewOptions , nextViewExpireTimer , forcedNav ;
45
+ var lastStateId , nextViewOptions , deregisterStateChangeListener , nextViewExpireTimer , forcedNav ;
46
46
47
47
var viewHistory = {
48
48
histories : { root : { historyId : 'root' , parentHistoryId : null , stack : [ ] , cursor : - 1 } } ,
@@ -367,6 +367,7 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
367
367
hist . stack . push ( viewHistory . views [ viewId ] ) ;
368
368
}
369
369
370
+ deregisterStateChangeListener && deregisterStateChangeListener ( ) ;
370
371
$timeout . cancel ( nextViewExpireTimer ) ;
371
372
if ( nextViewOptions ) {
372
373
if ( nextViewOptions . disableAnimate ) direction = DIRECTION_NONE ;
@@ -682,6 +683,7 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
682
683
* ```
683
684
*/
684
685
nextViewOptions : function ( opts ) {
686
+ deregisterStateChangeListener && deregisterStateChangeListener ( ) ;
685
687
if ( arguments . length ) {
686
688
$timeout . cancel ( nextViewExpireTimer ) ;
687
689
if ( opts === null ) {
@@ -690,9 +692,11 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
690
692
nextViewOptions = nextViewOptions || { } ;
691
693
extend ( nextViewOptions , opts ) ;
692
694
if ( nextViewOptions . expire ) {
693
- nextViewExpireTimer = $timeout ( function ( ) {
694
- nextViewOptions = null ;
695
- } , nextViewOptions . expire ) ;
695
+ deregisterStateChangeListener = $rootScope . $on ( '$stateChangeSuccess' , function ( ) {
696
+ nextViewExpireTimer = $timeout ( function ( ) {
697
+ nextViewOptions = null ;
698
+ } , nextViewOptions . expire ) ;
699
+ } ) ;
696
700
}
697
701
}
698
702
}
0 commit comments