How to hide sidemenu after exiting ion 2

I created a login and logout function. I gave an exit to the side menu. The logout functions are working correctly, but the problem is after the logout side menu. How to hide side menu after logout and go to home page.

enter image description here

+3


source to share


1 answer


You can use the directive menuClose

:

The directive menuClose

can be placed on any button to close the open menu.

A simple menuClose button can be added using the following markup:

<button ion-button menuClose>Close Menu</button>

      

or



<button ion-item menuClose>Close Menu</button>

      

This will cause the menu to close when you select the exit option from the side menu.


If you want more control over the menu, you can use MenuController

and use it to close the menu programmatically, starting with the component code.

import { Component } from '@angular/core';
import { MenuController } from 'ionic-angular';

@Component({...})
export class MyPage {

 constructor(public menuCtrl: MenuController) {

 }

 openMenu() {
   this.menuCtrl.open();
 }

 closeMenu() {
   this.menuCtrl.close();
 }

 toggleMenu() {
   this.menuCtrl.toggle();
 }

}

      

+7


source







All Articles