How to close side-menu upon navigation

I love the side-menus, but when a user chooses a link, I’d love for it to auto-close the menu.

I’ve tried injecting $ionicSideMenuDelegate to my controller, then having the navigation go through a function, but this seems overcomplicated and gives errors (possibly related to the interface for ionicSideMenuDelegate changing frequently, I get “Cannot read property ‘sideMenuController’ of undefined”).

Any suggestions?

Add a ‘menu-close’ directive in the links of your side-menu:

<ion-side-menu side="left">
    <ion-content>
      <ul class="list">
        <a nav-clear menu-close href="#/home" class="item">Home</a>
      </ul>
    </ion-content>
  </ion-side-menu>

Beautiful thanks; I now see where this is in the docs, duh :slight_smile:

Bah, I spoke too soon. It’s not working for some reason.

My side menu has it’s own controller, could that be the problem?

<ion-side-menu side="right" ng-controller="favorites">
    <button class="button" bo-href="'#/user/'+fav.name" menu-close ref='#'><i class='icon ion-arrow-right-c'></i></button>

I’ve tried to start a plunkr, but I can’t get the side-menus to work with the nightly, or I’m missing something in the simpler version…

I added menu-close to the ‘Attendees’ menu item so you can see the difference. Maybe you can start from there and see what your controller can do?

Once I updated to the 1.0 beta it started working, thanks!

Hi, I am having the same problem with ionic3. menuClose is not working on multiple tap from the side-menu