I’m trying to get what I thought was very basic functionality to work, but am unable, so am reaching out for help. I’ve checked the examples, and other issues on the forum, but haven’t had any luck.
My app uses the Side Menus - a Left and a Right menu. The Left menu has items for all the app’s main functions. The Right menu is a list of the app’s “friends” (app users who have signed up). One item in the Left menu is “Invite Friends”, which is supposed to toggle open the Right menu, to show a list of people that the user can select to invite to join the app.
So, the flow is supposed to be: User clicks the “Invite Friends” menu item in the Left menu. (This item does have “menu-close” as an attribute.) This action is supposed to toggle open the Right menu. But that’s not happening.
Here’s my Controller:
app.controller('MenuController', ['$scope', '$ionicSideMenuDelegate', function($scope, $ionicSideMenuDelegate)
{
$scope.toggleFriendsList = function()
{
$ionicSideMenuDelegate.toggleRight();
}
}]);
And here’s the HTML (remaining menu items omitted for brevity):
<div ng-controller="MenuController">
<ion-side-menus>
<ion-side-menu-content>
<ion-header-bar class="bar-royal" animation="nav-title-slide-ios7">
<div class="buttons left-buttons">
<button id="menu-left" menu-toggle="left" class="button button-icon icon ion-navicon"></button>
</div>
<div class="buttons right-buttons">
<button id="menu-right" menu-toggle="right" class="button button-icon icon ion-navicon"></button>
</div>
</ion-header-bar>
<ion-nav-view animation="slide-left-right">
</ion-nav-view>
</ion-side-menu-content>
<!-- Left Menu (actual application menu) -->
<ion-side-menu side="left" >
<ion-header-bar class="bar-royal">
<h1 class="title">Menu</h1>
</ion-header-bar >
<ion-content class="has-header">
<ion-list>
<ion-item menu-close class="item item-icon-left" ng-if="isAuthenticated()" ng-click="toggleFriendsList()">
<i class="icon ion-person-add"></i>Invite Friends<i class="icon item-icon-right ion-chevron-right menu-padding-special"></i>
</ion-item>
</ion-list>
</ion-content>
</ion-side-menu>
<!-- Right Menu (Friends list) -->
<ion-side-menu side="right" width="350">
<ion-header-bar class="bar-royal">
<h1 class="title">My Friends</h1>
</ion-header-bar>
<ion-content has-header="true" ng-controller="FriendsController">
<ion-list>
<ion-item ng-click="doFriend(item)" class="rs-item item-icon-right" ng-repeat="item in list" style="padding:0px">
....
</ion-item>
</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>
</div>
The toggleFriendsList()
function is definitely being called - it’s just the $ionicSideMenuDelegate.toggleRight()
isn’t doing anything.
Can anyone see what the problem is? I’ve tried using delegate-handle
, but got an error saying it couldn’t find an element with the handle name. I tried using $rootScope.$broadcast(event)
, sending an event to the FriendsController
, thinking that having nested Controllers was the problem; no joy either. I even resorted to document.getElementById('menu-right').click()
, and even that didn’t work. I give up. Help!
Thank you!