Hello, I am trying to trap the Android back button to always make sure that the last page before it exits the app is the Menu screen.
Let’s first look at the screen:
This is the menu screen. What you see on the left is actually a part of index.html – its not in a separate template file.
In other words, it has no state name associated to it. index.html code is here https://github.com/pliablepixels/zmNinja/blob/master/www/index.html
Now here is how I am trapping the android back button. My original logic that I thought I’d implement was check the state name, and if it tells me I am at my side menu, then I’ll exit the app, else if I am at any other state, I’ll go to the menu
$ionicPlatform.registerBackButtonAction(function (event) {
console.log("STATE NAME IS " + $ionicHistory.currentStateName());
if ($ionicHistory.currentStateName() == "whatd do I put here?") {
$ionicPlatform.exitApp();
} else {
// do something else
}
}, 100);
My problem is that the menu state is not really a state. When I tap the menu and it shows up, my “state name” is still the last view name.
So how do I handle this situation?
thx