user2374676
user2374676

Reputation: 65

navigate across history stacks ionic ion-tabs

I currently have a problem where I have a application that has 4 ion tabs of which they each have their own history stack. I am now having a problem where i navigate from say tab A => B, tab B is moved to inner page of tab B, but there is no way of navigating back and resetting the history on tab B so that when I go back to tab A I can reset tab B's history to the root of tab B.

Upvotes: 3

Views: 2948

Answers (1)

LarsBauer
LarsBauer

Reputation: 1545

If I get you right, do you want to clear the navigation stack within a tab when changing tabs? So have a look at the following approach:

<ion tab> has a callback when deselecting. You can use this to call a function in your controller which clears the history. So your html page looks for example like this:

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

And in your controller define the following coresponding 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.

I hope this was your issue. If not, leave me a comment and I will look again into it.

Upvotes: 5

Related Questions