Can't close the left menu since Beta-7

Hi all,

I encounter a problem on my application since I upgraded it to Beta-7.
I can’t close my LeftMenu, because the getComponent function has been deleted in this Ionic version.

So I understood that

let nav ='nav');

had to be replaced with :

@ViewChild(Nav) nav: Nav;

which works fine.

But how can I replace the following :'leftMenu').close();

? Thanks by advance !

For information, here is my app.html structure : (which I found in a Ionic template months ago)

<ion-menu id="leftMenu" [content]="content">


      <button ion-item *ngFor="let p of pages" (click)="openPage(p)">


<ion-nav id="nav" [root]="rootPage" #content swipe-back-enabled="false"></ion-nav>

Wo… Writing this topic, I found my solution alone :

I used :

@ViewChild(Menu) menu: Menu;

Sorry for the useless topic… I think I had to write it down :slight_smile:

Menu also has a MenuController that can be used from any page. The conference app uses this, for example:

import {MenuController} from 'ionic-angular';

  templateUrl: 'build/pages/tutorial/tutorial.html'
export class TutorialPage {
  constructor(private menu: MenuController) { }

  onPageDidEnter() {
    // the root left menu should be disabled on the tutorial page;

MenuController docs:

1 Like

Can you share the complete code? I use the @ViewChild(Menu) menu: Menu; but returns undefined

Here is my very simple code : (in app.ts file)

import {Nav, Menu} from 'ionic-angular';
class MyApp {

    private app;
    private platform;
    private pages;

    @ViewChild(Nav) nav: Nav;
    @ViewChild(Menu) menu: Menu;
    constructor(app: IonicApp, platform: Platform, private authHttp: AuthHttp, private auth: AuthService) {


    openPage(page) {
        // close the menu when clicking a link from the menu
        // navigate to the new page if it is not the current page;

If you try to access… in the constructor what do you get?

I think I tried, and indeed it was undefined.
Maybe you should use MenuController to access it in the constructor as @brandyshea mentioned.

I found out that in the constructor it never works so I access like you did