Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting next state from ionicView.beforeLeave

I know that there is $stateChangeStart function in angular that can perform action as follow.

$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {

});

However, i am developing an ionic v1 app, in which i would like to use a more intuitive way, which is the ionic life cycle. I am wondering if it is possible to get toState and toParams in $ionicView.beforeLeave as i am unable to find any documentation on this. eg:

$rootScope.$on('$ionicView.beforeLeave', function (event, toState, toParams) {

});
like image 704
vincentsty Avatar asked Nov 08 '22 02:11

vincentsty


1 Answers

The ionic $ionicView.beforeLeave event can take function with 2 arguments. From the argument you can get only from state, it will not give you to state.

    $rootScope.$on("$ionicView.beforeLeave", function(event, data){
   // handle event
        console.log("Event: ", event); 
        console.log("Data: ", data);
    })
like image 116
I. Ahmed Avatar answered Nov 15 '22 10:11

I. Ahmed