Hi, I’ve got a sidemenu powered app. I’m wondering that it would be a quite intuitive way of opening the side menu by using the hardware menu key that is present on Android devices. Could you please help me with that? I’ve tried the cordova method, but I’m probably not doing it the right way. My code:
darrenahunter, thank you for you help but unfortunately I still cannot make this work. My code is like this:
var myApp = angular.module('myApp', ['ionic', 'ngCordova', ... ])
.run(function($rootScope, $ionicPlatform, $cordovaSplashscreen, $ionicSideMenuDelegate, ...) {
$ionicPlatform.ready(function() {
if (window.cordova) {
$cordovaSplashscreen.hide();
document.addEventListener("menubutton", onHardwareMenuKeyDown, false);
}
});
myApp.onHardwareMenuKeyDown = function () {
LogService.add("Menu Button Pressed");
$ionicSideMenuDelegate.toggleLeft();
}
...
}) // end of .run
I’m rather sure I put the event handler in the wrong place, but you have mentioned that .run function is the place where it should go. Maybe some misunderstanding at my side. Or maybe the listener is in the wrong place? I assume that you have successfuly tried the code and your menu opens. Could you please share some more thoughts why this isn’t working in my case? TIA
I note you have my ‘LogService.add()’ function in your code. Assume this is just a copy paste for the forum as it is a unique service i run (unless you do too)