I have an app with two tab views, view 1 and view 2. When I switch to view 2, I need to do some things in view 1, before it switches to view 2. As part of this, I have the following code.
$scope.$on('$ionicView.beforeLeave', (event) => {
const stateName = $ionicHistory.currentStateName()
console.log('beforeLeave', stateName)
})
When I switch to view 2, I expect the console.log to print view 1
as the stateName, however it prints view 2
, which is counterintuitive because I would expect to return the state before I leave the view ie beforeLeave
.
Is there perhaps some other event I need to listen to?