distante distante - 5 months ago 45
AngularJS Question

Is there a direct way to know to which view I am going in ionic?

I have an interval running that I want to leave active if the user goes to a specific view.

Is there a way to check this in

or similar?


You don't have (shouldn't) to use an interval, you can't predict the exact time user will change states. However, there is the $stateChangeStart event, which is triggered when users navigate to another state and gives you the next state, so you can find the view you are going to. Also, you can check the current state if it's a matter or stop the state navigation by stopping the event default (i.e. event.preventDefault();).

            function (event, nextState, nextParams, currentState, currentParams) {
   // use the nextState to handle this
   // and use event.proventDefault() to stop the state change