In Ionic 2 when you use the NavBar, there is a back button automatically added. I want to observe with NG2 if a user clicks on it.
http://ionicframework.com/docs/v2/api/components/navbar/Navbar/
Any ideas how to achieve this?
In Ionic 2 when you use the NavBar, there is a back button automatically added. I want to observe with NG2 if a user clicks on it.
http://ionicframework.com/docs/v2/api/components/navbar/Navbar/
Any ideas how to achieve this?
Ionic did not expose any API for that, as far as I know.
But since this is Javascript, you can always hack it. You can add a click listener on that button if you know where it is in the DOM:
document.querySelector('ion-navbar button.back-button').addEventListener(event => {
//do stuff
});
You can override the Navbar
ViewChild in your page component
export class MyPage {
@ViewChild(Navbar) navBar: Navbar;
constructor(private navCtrl: NavController){}
ionViewDidLoad() {
this.navBar.backButtonClick = (e:UIEvent)=>{
// code here
this.navCtrl.pop();
}
}