How to quit app on specific page


Hello everybody :smile:

I have a little issues $ionicPlatform.onHardwareBackButton(); Indeed i don’t know how to use :s
i would like create a ionicpopup.confir for to quit app with back button is pressed on android. But i don’t see how to do.

i have that in my main controller but it’s doesn’t work :s

    alert("back button press");
        title: 'Quit TechForum 2014 app',
        content: 'Do you want to close TechForum app ?'
    }).then(function(res) {
        if(res) {

First i have test with ionic.platform in my main JS " app.js" before var app = angular.module(‘app’); but i don’t call a ionic fonction. I want to quit app when user is on main page ( with ion-tab) not when is on other page :s


Perhaps try injecting $state into your function and then checking the current state against the state you want to close on?


Did you try changing $ionicPlatform.exitApp(); by ionic.Platform.exitApp();


It’s does’nt work, when i tap on back button, i back on a previous page and after display a popup.
And when i click on " Cancel" and re-click on backbutton, a popup display two time, and tree time if i click 3 time on “cancel”


In a doesn’t work. and how to blocked a back a page view when i click on a back button ?