Ionic 2 customize back button action
For customize default back button action you need override the backButtonClick() method of the NavBar component.
Step 1: In your "custom-class.ts" import Navbar component. Create auxMethod for override the default behavior and called in your ionViewDidLoad method.
import { Navbar } from 'ionic-angular';
import { ViewChild } from '@angular/core';
export class myCustomClass {
@ViewChild(Navbar) navBar: Navbar;
ionViewDidLoad() {
this.setBackButtonAction()
}
//Method to override the default back button action
setBackButtonAction(){
this.navBar.backButtonClick = () => {
//Write here wherever you wanna do
this.navCtrl.pop()
}
}
}
This code has been tested in ionic 3.