Hello, I have the following code in index.html to show a side menu:
<body>
<!-- This is the Side menu options -->
<ion-side-menus>
<ion-side-menu-content>
<ion-nav-bar class="bar-stable nav-title-slide-ios7">
<ion-nav-back-button class="button-icon">
<span class="icon ion-ios7-arrow-left"></span>
</ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view></ion-nav-view>
</ion-side-menu-content>
<ion-side-menu side="left">
<ion-header-bar class="bar bar-header bar-dark">
<h1 class="title">Options</h1>
</ion-header-bar>
<ion-content has-header="true">
<ion-list>
<ion-item href="#/montage" menu-close>
<span class=" item-icon-left">
<i class="icon ion-ios-eye"></i>
</span>Montage View
</ion-item>
<!-- other menu items removed for brevity -->
<ion-item nav-clear menu-close href="#/log">
<span class=" item-icon-left">
<i class="icon ion-clipboard"></i>
</span> Logs
</ion-item>
</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>
<!-- This is where is bootstrap angular - if I don't do this, then the window jumps around
after the status bar comes on - because the window kicked in before phonegap got ready -->
<script>
window.ionic.Platform.ready(function() {
console.log("******* PLATFORM READY ****");
angular.bootstrap(document, ['zmApp']);
});
</script>
</body>
Now inside app.js I have the following code to trap the Android back button and display status of side menu:
.run(function ($ionicPlatform, $ionicPopup, $rootScope, zm, $state, ZMDataModel, $cordovaSplashscreen, $http, $interval, zmAutoLogin, $fileLogger,$timeout, $ionicHistory, $window, $ionicSideMenuDelegate)
{
$ionicPlatform.registerBackButtonAction(function (event) {
$ionicSideMenuDelegate.toggleLeft();
console.log ("Status of SIDE MENU IS : " + $ionicSideMenuDelegate.isOpen());
}, 100);
The trapping works, and each time I press th back button, the menu slide toggles, but the status of isOpen is always FALSE.
This is a problem for me, because I want to exit the app if the status is TRUE - and it never shows as true.
I canāt figure out how to solve this problem. One could think of putting a global variable and toggling but I really donāt like to do that. Plus there are multiple areas in the code where the menu toggles/ My understanding is the SideMenu is a singleton - and I am only using the left part, so Iām confused why this is not working. Any help?
(Updated: I event tried adding a delegate-handle to the menu, and using $ionicSideMenuDelegate.$getByHandle('sideMenu').isOpen()
ā makes no difference
thx