and after
Openlogin.ts and import theMenuController from ionic/angular.
The following worked for me on Ionic2 v.2.2.0
Open src/app/app.html and add an ID to your element
So that this,
<ion-menu [content]=âcontentâ>
Becomes this.
<ion-menu id=âmyMenuâ [content]=âcontentâ>
Open login.html and remove the code from so that the menu will not display on the page.
Open login.ts and import the MenuController from ionic/angular.
In the constructor set enable() on MenuCtrl to false and add the menu ID as the second parameter. Even though the menu isnât showing, doing this will prevent the user from swiping to open the menu.
constructor(
public navCtrl: NavController,
public menuCtrl: MenuController
) {
this.menuCtrl.enable(false, 'myMenu');
}
I could deactivate the lateral menu on the login page, since that menu should only appear when the user is already on the home page,
The first thing I did was to follow in Madhawaâs footsteps, that is, assign an id to the menu and then disable it with
this.menuCtrl.enable (false, âmyMenuâ);
however this disabled my menu in the whole application so after I had to re-activate it on the home page.ts
The menuCtrl works, but I was having some issue using it with the ion-split-pane when the device screen is large. It only disables the menu when the page is loaded and we may need it to be disabled a few milliseconds before that.
If we setup a variable that holds user information right after a success login, clear it on logout and put it into the enabled attribute of ion-split-pane it does the do job really well.
<ion-split-pane [enabled]="authentication.user">
Authentication in this example is a provider that does a few HTTP requests for the LoginPage.
What if I want to disable a button based on a condition inside the side menu? The condition needed to check will be available only after I login to the application. In the app.component.ts Iâm defining my pages like