Hello,
Here i am sharing a method by which we can open side menu in side-menu ionic app by clicking the hardware back button, and it will be happened when side menu is closed, and we clicked on hardware back button than side menu will open . And if side menu is open than a pop up will be show on screen for exiting from app by clicking on hardware back button.
So we include following code in our app.js
.run(function ($ionicPlatform, $cordovaStatusbar, $ionicPopup,$ionicSideMenuDelegate ) { $ionicPlatform.onHardwareBackButton(function () {
if ($ionicSideMenuDelegate.isOpen()) { // your check here $ionicPopup.confirm({ template: '<div style=" color:#255B73; text-align: center; font-size:18px;">Exit the app?</div>', buttons: [ { text: 'Cancel' }, { text: '<b>Exit</b>', type: 'button-positive', onTap: function () { return true; } } ] }).then(function (res) { if (res) { navigator.app.exitApp(); } }) } else { $ionicSideMenuDelegate.toggleLeft() }
});
})
Thanks....
No comments:
Post a Comment