angularjs - how to restore ionic backbutton after override? - breaking backbutton on other tabs -


currently backbutton override on particular page working on particular tab-subtab (a) applying - on subtaba, button takes me taba, $scope.$on('$destroy...) doesn't seem working. because if tab-subtab(a) , navigate directly tab-subtab (c) page - button on tab-subtab (c) takes me directly taba instead of tabc.

furthermore, if go tabc - takes me directly tab-subtabc (because thats last left off) , can never tabc.

below controller particular page/tab on:

  $scope.$on('$ionicview.beforeenter', function(){       // none related stuff here.   }) ;   // custom button send user master rides tab no matter how many subviews navigate   //   //   var docustomback = function() {       $state.transitionto('tab.rides');   };   // override soft   // framework calls $rootscope.$ionicgoback when soft button pressed   var oldsoftback = $rootscope.$ionicgoback;   $rootscope.$ionicgoback = function() {       docustomback();   };   var deregistersoftback = function() {       $rootscope.$ionicgoback = oldsoftback;   };   // override hard   // registerbackbuttonaction() returns function can used deregister   var deregisterhardback = $ionicplatform.registerbackbuttonaction(       docustomback, 101   );   // cancel custom behaviour   $scope.$on('$destroy', function() {       deregisterhardback();       deregistersoftback();   }); 

i thought $scope.$on('$destroy'...) prevent happening, not.

visual of navigation:

tab (controller: taba)    -> sub tab a1 (controller: subtaba)  <- above backbutton overrides here tab b (controller: tabb)    -> sub tab b1 (controller: subtabb) tab c (controller: tabc)    -> sub tab c1 (controller: subtabc) tab d (controller: tabd) 

across top of app is

home    taba     tabb     tabc     tabd  if got taba -> subtaba, click button, takes me taba if got taba -> subtaba, go directly tabc (from top of app) -> subtabc,  button on subtabc takes me directly taba content. 

the problem $destroy not triggering fast enough before statechange. moved this:

  1. change: var oldsoftback = $rootscope.$ionicgoback to:

$rootscope.oldsoftback = $rootscope.$ionicgoback ;

  1. instead of $scope.$on('$destroy'...) use this:

var backstatechangewatcher = $rootscope.$on('$statechangestart', function () {    if($rootscope.oldsoftback){      deregisterhardback();      deregistersoftback();      // un-register watcher      backstatechangewatcher();       }  }) ;


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -