1

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?

Pradnya Sinalkar
  • 1,116
  • 4
  • 12
  • 26
JackDev
  • 4,891
  • 1
  • 39
  • 48

1 Answers1

0

So it looks like the event $stateChangeStart does the trick that I am looking for, and what I would expect beforeLeave to do.

JackDev
  • 4,891
  • 1
  • 39
  • 48