I have used registerBackButtonAction in one controller, so it should be called just in that view using that controller.
But it happens that the back button is like disabled and to make it work i should implement the behavior in each controller related to a view.
Also i would like to link a animation like “nav-direction=back” used in a view, is it possible?
You can put the registerBackButtonAction in the app’s run function and then check the state that you are in to only override it on that state:
app.run(function($ionicPlatform, $state) {
$ionicPlatform.registerBackButtonAction(function () {
if ($state.current.name == "stateToOverride") {
// override the back button for this state
// Clear the history before navigating back since these are top level menu items
} else {
navigator.app.backHistory();
}
}, 100);
});
I don’t understand your second question. Can you explain what you mean?
Thanks!
I was thinking to put it in the app’s run function, mine was more an idea to put it into the controller to see if it works just in that case :).
I try to explain better my other question:
When i click the back button in a device the view comes from left to right instead of from right to left, so i would like to control this animation, i hope i explained myself
Also i have another doubt:
I have this navigation path with different states:
A -> B -> C -> D
When i press the back button on my device works fine going back forward:
A <- B <- C <- D
but when i am in the state D, i have a ng-click that calls a service and then i call the history back:
Yes!
that is the solution!
But now i have another weird behavior:
I have used one code pen and changed a bit: http://codepen.io/anon/pen/RNOJRN
From the home you go to page B then page C, then go back to page B and then again to page C, in this moment if i decide to go back with the back button of my device it goes to page B then C then B again and finally A, the behavior that i expect is that should go directly to A