Close menu after backbuttonaction

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);
        }
      });

Take a look at the menucontroller

I’m try to close that menu o "backbutton press!

I found this

registerBackButtonAction(fn, priority) sounds interesting.

It’s not work, i try this…

Danilo please show me your close function…

Danilo me mostra sua função fechar por favor…

Seeya

I think fn must be the function Name

registerBackButtonAction(myCloseFunktion(), 0);

myCloseFunction(){
  // Doing some stuff
}

Close the “Search Menu” ICON search

 public pesquisar(){
        this.opcoesjs = true;
        $("#opcoes").css("display","none");
        $("#inputBusca").css("display","flex");

        if(this.visivel == true){
            this.visivel = false;
            $('.inputInfosys2').css("visibility", "visible")
            $('#botaoInfosys2').css("visibility", "visible");
            $("#inputBusca").css("visibility", "visible").animate({
                width: "70%",
                height: "80px"
            }, 500, function() {
            })
        }else{
            this.visivel = true;
            $('.inputInfosys2').css("visibility", "hidden");
            $('#botaoInfosys2').css("visibility", "hidden");
            $("#status").css("visibility","hidden");
            $("#inputBusca").animate({
                width: "0px;",
                height: "0px"
            }, 500, function() {
                $(this).css("visibility", "hidden")
            })
        }
    }
public opcoes(){
        this.visivel = true;
        $("#inputBusca").css("display", "none");
        $("#opcoes").css("display","flex");

        if(this.opcoesjs == true){
            this.opcoesjs = false;
            $("#opcoes").css("visibility", "visible").animate({
                    width: "150px",
                    height: "180px"
                }, 200, function() {
            })
        }else{
            this.opcoesjs = true;
            $("#opcoes").animate({
                    width: "0px",
                    height: "0px"
                }, 200, function() {
            }).css("visibility", "hidden");
        }
    }

Close the other menu “…” vertical

Take a look in the menu css via dev tools if css variables are being assigned as well… If so, show me your menu file structure…

Da uma olhada se o css esta sendo atribuido corretamente… Se estiver me mostra sua estrutura de arquivos do menu…

It’s working css I just wanted to close it when I hit the “backbutton”