Can I close the side menu automatically when an item is clicked?

Here’s a codepen showing a simple side menu.

Assume that the first menu item corresponds to the currently visible page (e.g., #/selected). So clicking it doesn’t cause the URL to change.

I’m wondering, can I put something into the HTML on the left so that the side menu closes chooses the first menu item?

This does the trick:

Use the ng-click directive to trigger a method that is available on the current scope. In this case, I’m using the $ionicSideMenusController which exposes itself to the current scope. This controller has the ability to programmatically trigger the side menu with toggleLeft(), toggleRight(), openLeft() and openRight()

More documentation on this follows as soon as beta 1.0 lands on the moon (which is expected to happen within the upcoming week)

1 Like