How to custom back button default in ionic 2 rc0?


#1

hi all,
please help me custom back button in ionic 2 rc0. I want to change icon and text in all page which using back button. any way to do it?

thank all


#2

use any button, and call a function to pop out the view like with this line:

this._navController.pop();


#3

Please show more info. so, I think I have to loop this code in each page. It’s not good.


#4

well, yes, indeed is needed in every component you want to implement if you wan a custom back button, maybe you can implement it as a service.

So, in template is

<button ion-button (click)=“goBack()”>Custom back button

In ts file:
import { NavController } from ‘ionic-angular’;

in constructor define:

constructor(public _navController: NavController ){ … }

and after constructor function:

goBack() {
this._navController.pop();
}

That’s it


#5

instead of injection navcontroller you can simply add a button and use the “navPop” directive at this button:

<button ion-button navPop>Back</button>

#6

It work well, Thanks


#7

That’s good to know!! great!