Try the following: in .run ()
$ionicPlatform.ready(function() { //... if (window.cordova) { $cordovaSplashscreen.hide(); document.addEventListener("menubutton", myApp.onHardwareMenuKeyDown, false); } /...
Then in the controller:
$scope.onHardwareMenuKeyDown = function() { alert('menu button is working'); }
Another way to do something:
angular.module('myApp', ['ngCordova', 'ionic', 'myApp.controllers']) .run(function($ionicPlatform, $rootScope, $state, $localstorage,$ionicSideMenuDelegate ) { $ionicPlatform.ready(function() { document.addEventListener("menubutton", onMenuKeyDown, false); function onMenuKeyDown() { console.log("some menu pops pup!! ");
source share