Based on @eray’s solution, what I did was just to override $ionicGoBack
in one of my controllers. Before doing so, I grabbed a handle to the default implementation - this can be used to call back into on completion of the custom code, or to deregister the custom handler at some point.
I place this code inside one of my controllers:
// override soft back button
// framework calls $rootScope.$ionicGoBack when soft back button is pressed
var oldSoftBack = $rootScope.$ionicGoBack;
$rootScope.$ionicGoBack = function() {
// implement custom behaviour here
};
My requirement is controller specific, so I deregister the custom handle when the controller exits:
var deregisterSoftBack = function() {
$rootScope.$ionicGoBack = oldSoftBack;
};
More details can be found on my related StackOverflow post: