How to disable side menu?

<ion-menu [content]="root_nav" #side_menu>
	<ion-header>
		<ion-toolbar>
			<ion-title>Menu</ion-title>
		</ion-toolbar>
	</ion-header>

	<ion-content>
		<ion-list>
			<ion-item  menuClose *ngFor="let p of pages" (click)="openPage(p)">
				<ion-icon [name]="p.icon" item-left></ion-icon>
				{{ p.title }}
			</ion-item>
		</ion-list>
	</ion-content>
</ion-menu>

<!-- Disable swipe-to-go-back because it's poor UX to combine STGB with side menus -->
<ion-nav [root]="rootPage" #root_nav swipeBackEnabled="false"></ion-nav>

In my controller I’m trying like this:

export class App {
	@ViewChild('root_nav') nav: NavController

	private rootPage: any;

	public pages = [
		{title: 'On Test', component: OnTestPage, icon: 'flash'}
	]

	constructor(
		private platform: Platform, 
		private events: Events,
		private auth: Auth,
		private menuCtrl: MenuController
	) {
		this.menuCtrl.enable(false, 'side_menu')

		platform.ready().then(() => {

Did you end up figuring out a good way to do this? I am currently using the following code in my login page. It works, just wondering if there’s a best practice I’ve overlooked.

// close and disable the side menu.  I don't want them accessing this unless they're logged in.
this.menuCtrl.close();
this.menuCtrl.enable(false, 'side_menu');
1 Like

What about binding to the [enabled] input of the sidemenu? You can set it to true or false from wherever you want. Bind the value to one shared in a shared service and you’re good to go.