sasi sasi - 9 days ago 7
AngularJS Question

How to enable/disable the left/right side menu ionic

I have both left and right side menus in my page. My app has English/Arabic translation. When in english language the panel should be from left side and for the arabic the panel should be from right side.

So I am planning to have both the menus in my page and enable/disable the left/right panel menu according to the language.

My menu page will look something similar to below:

<ion-side-menus>
<!-- Left menu -->
<ion-side-menu side="left" is-enabled={{enableLeftMenu}}>
</ion-side-menu>

<ion-side-menu-content>
<!-- Main content, usually <ion-nav-view> -->
</ion-side-menu-content>

<!-- Right menu -->
<ion-side-menu side="right" is-enabled={{!enableLeftMenu}}>
</ion-side-menu>

</ion-side-menus>


So I am trying to play with
"is-enabled"
attribute.
http://ionicframework.com/docs/api/directive/ionSideMenu/

But the problem is when I change the value of
is-enabled
attribute from controller, it is not getting affected in the view.

Answer

You'll need to inject $ionicSideMenuDelegate into your controller and then use the toggleLeft() or toggleRight() function on it, depending on which menu you want to toggle.

Hope that helps!