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:
login.page.ts
constructor(public loginService: LoginService, private router: Router, public menuCtrl: MenuController) {
this.menuCtrl.swipeEnable(false);
}
app.component.html
<ion-app>
<ion-split-pane>
<ion-menu type="push">
<ion-header>
<ion-toolbar color="success">
<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>
this.menuCtrl.enable(false);
This will also work in constructor. I am using this in an ionic v4 - beta.2 project and it works fine.
Also, I see that you are using ionic
with angular
so you can also OnInit lifecycle hook.
Try
this.menuCtrl.enable(false);
This also seems to be answered here disable menu on login page ionic 4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With