I have a home page and I navigate like this to various pages.
Home -> A (back) -> Home
Home -> B (back) -> Home
Home -> C -> ( back) -> Home
I want to go Home -> C. and then from C… i want to go -> A but if you hit the back button, i want it to go Home, not back to C. Is there a way to do that?
Home -> C —> Optional Route to A --> (back) --> Home.
You can override the back-button behavior on an individual page
Import Navbar
import { Component, ViewChild } from '@angular/core';
import { NavController, Navbar } from 'ionic-angular';
Get a reference to the navbar @ViewChild(Navbar) navBar: Navbar;
On page enter, replace the back button function
ionViewDidLoad() {
this.navBar.backButtonClick = () => {
// you can set a full custom history here if you want
let pages = [
{
page: HomePage
}
];
this.navCtrl.setPages(pages);
}
}