I have view that I get to him after a wizard.
I want the back button to take directly to home view.
I saw the solution to point to the previous-previous, How to manipulate a back button pointer to point to a previous-previous View.
But, In my case I have multiple steps in creation process, so the above solution will destory the back at each step.
So, one solution is to use hide-back-button="true" and add left button with "ui-sref=home". But this solution removes the back button animation that creates the very important native feel.
Is there a way to set the back-button “back state” kind of state.go("home") ...
// This will show you the history stuff.
var history = $ionicViewService.getBackView();
console.log(history);
$ionicViewService.goToHistoryRoot("002");
The back-button itself doesn’t have an API that allows you to tell it where to go.
$rootScope.$on('$stateChangeSuccess', function (ev, to, toParams, from, fromParams) {
//assign the "from" or "to" parameter to something
console.log(from)
});
Pretty much you can see to.name as the page you are going to; and from.name as the state you are coming from.
if (from.name == "app.view2" && to.name =="app.view1"){
// do something when you go from state app.view2 to state app.view1
}
Full code:
$rootScope.$on('$stateChangeSuccess', function (ev, to, toParams, from, fromParams) {
if (from.name == "app.view2" && to.name =="app.view1"){
//do something
}
});