Move through historical stacks of ionic ionic tabs

I currently have a problem where I have an application that has 4 tabs with ions, each with its own history stack. I have a problem when I navigate to the scanned tab A => B, tab B moves to the inner page of tab B, but there is no way to navigate back and reset the history in tab B, so when I go back to tab AI can reset keep tab B to the root of tab B.

+3


source to share


1 answer


If I understand correctly, you want to clear the navigation stack on a tab when the tabs change? Therefore, consider the following approach:

<ion tab>

has a callback when deselecting. You can use this to call a function in the controller that clears the history. Therefore your html page looks like this:

<ion-tab title="xyz" href="#/tab/whatever" on-deselect="clearHistory()">
   ...
</ion-tab>

      

And in your controller, define the following function:



.controller('TestCtrl', function($scope, $ionicHistory) {
   $scope.clearHistory = function() {
      $ionicHistory.clearHistory();
   }
})

      

This clears this navigation stack of the current tab before leaving. I tested it with the ionic tabs starter templates and it worked for me.

Hope this was your problem. If not, leave me a comment and I'll look at it again.

+5


source







All Articles