Ionic routes used angular ui-router therefore event callbacks are used in the same way:
ui-router
Where appropriate:
$rootScope.$on('$stateChangeStart', function(ev, toState, toParams, fromState, fromParams){
if(toState.name == 'stateA' && fromState.name == 'stateB') {
// run your code
$scope.run();
}
});
(UPDATE)
if you need to ask for more than one state:
$rootScope.$on('$stateChangeStart', function(ev, toState, toParams, fromState, fromParams){
var states = ['stateB', 'stateC', 'stateD'];
if(toState.name == 'stateA' && states.indexOf(fromState.name) > -1) {
// run your code
$scope.run();
}
});