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

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:

Dear @brandyshea,

This is Fausto from Italy and I recently follow your old but gold notices, long my first approach in Ionic.
In particular I’m focus on the routing. Really hard for me to understand… well in order to your replay concerning the sidemenu visibility, I really appreciate if you can suggest me something about my case.

import { NgModule } from ā€˜@angular/core’;
import { MenuController } from ā€˜@ionic/angular’;
import { PreloadAllModules, RouterModule, Routes } from ā€˜@angular/router’;

const routes: Routes = [
{
path: ā€˜ā€™,
redirectTo: ā€˜login’,
pathMatch: ā€˜full’
},
{
path: ā€˜dashboard’,
loadChildren: () => import(’./pages/dashboard/dashboard.module’).then( m => m.DashboardPageModule)
},
{
path: ā€˜lista-clienti’,
loadChildren: () => import(’./pages/lista-clienti/lista-clienti.module’).then( m => m.ListaClientiPageModule)
},
{
path: ā€˜user-profile’,
loadChildren: () => import(’./pages/user-profile/user-profile.module’).then( m => m.UserProfilePageModule)
},
{
path: ā€˜templates’,
loadChildren: () => import(’./pages/templates/templates.module’).then( m => m.TemplatesPageModule)
},
{
path: ā€˜support-request’,
loadChildren: () => import(’./pages/support-request/support-request.module’).then( m => m.SupportRequestPageModule)
},
{
path: ā€˜login’,
loadChildren: () => import(’./pages/login/login.module’).then( m => m.LoginPageModule)
}
];

@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule {}

How i can solve this tricky…?