Side Menu BackButton


Hi, I have a problem using SideMenu when I navigate the view (using href = “# / app / templaten” and pressed the physical button again (Android) I navigate back obviously in history mode. What I want to do is to by pressing the physical button back, I exit the application. Anyone have any idea?
Thanks :smile:


Can you provide a sample app of what you have?


Try using registerBackButtonAction as suggested at registerBackButtonAction and then call ionic.Platform.exitApp() or if the current state is your view’s state.

I haven’t tried this that but will have to soon so be interested to see if it works.


As a follow up verified this works for me:

.run(function($ionicPlatform, $rootScope, $state) {
    $ionicPlatform.ready(function() {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins.Keyboard) {
        if (window.StatusBar) {
            // org.apache.cordova.statusbar required

        // Override the android back button
        $ionicPlatform.registerBackButtonAction(function () {

            if ($ === "app.home") {
            else if($ === "app.assessments") {
            else {

        }, 100);



Hi, thanks for sharing your code. I tried it and did not worked. as I spend with thousands of codes that probe. I found the problem was a problem of platform when executing that sentence gave me error compiling worked OK but not the Cordova. then I realized my stupid mistake app take Exit function of your code, ignoring the conditional IF, and then will incorporate a popup. thank you very much.