I created 2 menus and after opening the options I want it to close the menus before it goes to the root page. This my backbuttonaction () method causes the menu to close but is not running
PedidosPage
public backButtonAction(){
if(this.visivel == false){
this.visivel = true;
this.pesquisar(); // that function closes the input search
}else if(this.opcoesjs == false){
this.opcoesjs = true;
this.opcoes();
}else{
this.navCtrl.setRoot(OrcamentoPage);
}
}
In app.component.ts i have that code
this.platform.registerBackButtonAction(() => {
let activePortal = this.ionicApp._loadingPortal.getActive() ||
this.ionicApp._modalPortal.getActive() ||
this.ionicApp._toastPortal.getActive() ||
this.ionicApp._overlayPortal.getActive();
let view = this.nav.getActive();
let currentRootPage = view.component;
if (activePortal) {
activePortal.dismiss();
}
else if (this.menuCtrl.isOpen()) {
this.menuCtrl.close();
}
else if (this.nav.canGoBack() || view && view.isOverlay) {
this.nav.pop();
}
else if (currentRootPage == HomePage) {
this.appMinimize.minimize().then(
success => console.log('Fechado'),
err => console.log('Algo errado:')
);
} else if (currentRootPage == OrcamentoPage) {
let alert = this.alertCtrl.create({
title: 'Deseja fazer logoff ?',
message: '',
buttons: [
{
text: 'Cancelar',
role: 'cancel',
handler: () => {
alert.dismiss();
}
},
{
text: 'ok',
handler: () => {
this.nav.setRoot(HomePage);
}
}
]
});
alert.present();
}else if (currentRootPage == PreferenciasPage) {
this.nav.setRoot(OrcamentoPage);
}else if (currentRootPage == CargaPage) {
this.nav.setRoot(OrcamentoPage);
}else if (currentRootPage == EnviarOrcamentoPage) {
this.nav.setRoot(OrcamentoPage);
} else if (currentRootPage == CarrinhoPage) {
this.nav.setRoot(OrcamentoPage);
} else if (currentRootPage == FinalizaPage) {
this.nav.setRoot(OrcamentoPage);
} else if (currentRootPage == ConfigPage) {
this.nav.setRoot(HomePage);
}
});