How can I clear the history for only one tab?

#1

$ionicViewService.clearHistory() clears the history for all tabs, how would I go about clearing it only for a single tab?

The use case is that I have 3 tabs, within one of the tabs I have the “user manual,” which can be accessed by a link on every page. When a user switches back to the tab with the user manual, they will see the most recently viewed help page. I would like to take them back to base page on that tab.

2 Likes
#2

+1 bump, i would like to know how to do this also.

#3

Another +1 for this.

Since parallel histories are maintained for tabs, we should be able to clear a single tab history.

Another use case for this is a shopping app, where one tab is for browsing and another tab has the shopping cart. You probably will need to clear the cart history after payment but you may want to keep the browsing history alive.

Any ideas how to achieve this? (thanks in advance)

#4

Try this

<ion-tab ng-click="loadRootView('tabrootstate')"></ion-tab>

$scope.loadRootView = function(state) {
      $state.go(state, {}, {
        reload: true,
        inherit: false,
        notify: true
      });
    };
2 Likes
#5

This absolutely did it for me. Thanks.

#6

Thanks! Work like a charm!