I am using ionic v1.0.0-beta.1 “actinium” and following the “ionic start myApp sidemenu” example on the getting started page. I am having trouble implementing a contextual side menu based on which state I transition to. For example, when on a ‘app.todos’ state I would like the side menu to show something like:
<ion-list>
<ion-item ng-if="currentPath === '/app/mycustomers'" class="item item-icon-left" nav-clear menu-close href="#/app/mycustomers">
<i class="icon ion-person-stalker"></i>
My Customers
</ion-item>
<ion-item class="item item-icon-left" nav-clear menu-close href="#/app/todos">
<i class="icon ion-clipboard"></i>
Todos
</ion-item>
<ion-item class="item item-icon-left" nav-clear menu-close href="#/app/logout">
<i class="icon ion-log-out"></i>
Logout
</ion-item>
</ion-list>
And then on on a ‘app.customers’ state, a list with additional items:
<ion-list>
<ion-item ng-if="currentPath === '/app/mycustomers'" class="item item-icon-left" nav-clear menu-close href="#/app/searchbycustomer">
<i class="icon ion-person-stalker"></i>
Search By Customer
</ion-item>
<ion-item class="item item-icon-left" nav-clear menu-close href="#/app/searchbydate">
<i class="icon ion-person-stalker"></i>
Search by Date
</ion-item>
<ion-item ng-if="currentPath === '/app/mycustomers'" class="item item-icon-left" nav-clear menu-close href="#/app/mycustomers">
<i class="icon ion-person-stalker"></i>
My Customers
</ion-item>
<ion-item class="item item-icon-left" nav-clear menu-close href="#/app/mycustomers">
<i class="icon ion-person-stalker"></i>
My Customers
</ion-item>
<ion-item class="item item-icon-left" nav-clear menu-close href="#/app/todos">
<i class="icon ion-clipboard"></i>
Todos
</ion-item>
<ion-item class="item item-icon-left" nav-clear menu-close href="#/app/logout">
<i class="icon ion-log-out"></i>
Logout
</ion-item>
</ion-list>
I added a currentPath to my settings controller:
var currentPath = $location.$$path;
But it seems like the menuController isn’t instantiated when transitioning to a new view so the path never updates. Any ideas how to implement this?
Thanks in advance!