Ionic Tabs Clear history after naivgation

I am navigating between tabs using the following

this.navCtrl.parent.select(0);

After navigation I do not want the hardware back button to take me back.

Is there a way to clear history after navigating between tabs??

1 Like

Hi @almighty99 - did you ever find a solution to this?

Quick update. I found a solution. I used the ionChange event:
<ion-tabs (ionChange)="tabChanged($event)">

When this fires, the event provides the tab being navigated to. In my case I only wanted to ditch history on one of my tabs. Adding below worked well:

tabChanged($ev){
  if($ev.tabTitle === "TITLE_HERE"){
    $ev.setRoot(PAGE_HERE);
  }
}

I handled the hardware back button using something similar

  platform.registerBackButtonAction(()=>{
})

Its working perfectly Thanks

I too had the same issue. Solution is as below.

initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();
      document.addEventListener("backbutton", () => {
        // code that is executed when the user pressed the back button. You can use any one of the below lines.
        // window.history.back();
        this.location.back();
      });
    });
  }