Disable side menu on login page conference app

hi

import {IonicApp} from 'ionic/ionic';

Do i have to install IonicApp in my ionic its not working

displaying cannot reaD PROPERTY enable OF NULL

Where is this coming from??
import {IonicApp, Page, NavController} from ‘ionic/ionic’;

That comment is pretty old, the syntax has changed. The docs for the latest version can be found here: http://ionicframework.com/docs/api/components/app/MenuController/

<ion-menu id="authenticated" side="left" [content]="mycontent">...</ion-menu>
<ion-menu id="unauthenticated" side="left" [content]="mycontent">...</ion-menu>
<ion-nav #mycontent [root]="rootPage"></ion-nav>
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();
 }

  enableAuthenticatedMenu() {
    this.menuCtrl.enable(true, 'authenticated');
    this.menuCtrl.enable(false, 'unauthenticated');
  }
}

The source for the API demo is here: https://github.com/ionic-team/ionic/blob/master/demos/src/menu/pages/page-one/page-one.ts

Edit: updated my previous comment with the correct syntax.

import { MenuController } from ‘ionic-angular’;

constructor(… … … …,private menu : MenuController)

ionViewDidEnter() {
// the root left menu should be disabled on this page
this.menu.enable(false);
}

ionViewWillLeave() {
// enable the root left menu when leaving this page
this.menu.enable(true);
}

this will hide the menu

1 Like

ionViewDidLoad() {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
this.statusBar.styleDefault();
this.menu.enable(false, ‘leftMenu’);
this.menu.swipeEnable(false, ‘leftMenu’);
this.splashScreen.hide();
});
}

<ion-menu id=“leftMenu” [content]=“content”>

Doesnt work for me :frowning:

I want to disable swipe and enable whne I know someone is logged in

thanks worked like charm

that working … and thanks …

it works :slight_smile: thanks…

Note, it’s important to use ionViewWillEnter and not ionViewDidEnter, to ensure that the view events are captured in the right order. If you use DidLeave and DidEnter, you could find that page 1’s DidLeave may fire after page 2’s DidEnter, with the net result that the side menu is incorrectly left enabled by the page 1 code.

Hi there… i’m trying to close the menu in a desktop view… but this do not work… it always show up the menu… this make the menu closed just when mobile views (smaller sizes)

The enable false works… but removes the hamburguer button to open it again… the close does not close at all
What i tested

    this.menuCtrl.swipeEnable(false);
    this.menuCtrl.enable(false); ```

forget about it… my bad… was using a split pane component

I’ve solved this with this line in my login constructor :
this.menu.enable(false);

Thanks this worked for me ! :slight_smile: