How to disable side menu in ionic 4?

I am using,

this.menuCtrl.swipeEnable(false);

for ionic 3 app. This works fine for disabling the side menu. But, it doesn’t work for ionic 4! Below is my ionic 4 code sample:

FYI: You forgot your code sample.

1 Like

What do you mean by this? I don’t understand!

Where’s the code? Maybe you forgot to past the code here.

constructor(public loginService: LoginService, private router: Router, public menuCtrl: MenuController, public loadingController: LoadingController) {
    this.menuCtrl.enable(false);
  }
<ion-app>
  <ion-split-pane>
    <ion-menu>
      <ion-header>
        <ion-toolbar>
          <ion-title>Menu</ion-title>
        </ion-toolbar>
      </ion-header>
      <ion-content>
        <ion-list>
          <ion-menu-toggle auto-hide="false" *ngFor="let p of appPages">
            <ion-item [routerDirection]="'root'" [routerLink]="[p.url]">
              <ion-icon slot="start" [name]="p.icon"></ion-icon>
              <ion-label>
                {{p.title}}
              </ion-label>
            </ion-item>
          </ion-menu-toggle>
        </ion-list>
      </ion-content>
    </ion-menu>
    <ion-router-outlet main></ion-router-outlet>
  </ion-split-pane>
</ion-app>

Hello, please see my code.

I know its its late reply but hope it help someone in future
u can use this on ur login page and it will disable the menu on the login page

import {  MenuController } from '@ionic/angular';

constructor( public menuCtrl: MenuController,){ }
ionViewWillEnter() {
   this.menuCtrl.enable(false);
  }
9 Likes

@aditbharadwaj Well, It’s working. Thank you so much.

1 Like

Great. Works perfectly .

1 Like