How to know view come back


#1

now I have a scene :
When user click go to last page , I want restore last page status .
I should konw the page is back , how can i know this information.

How to do this ?

Thanks for your help.


#2

You can listen to $stateChangeSuccess (or any other $state event) and save the fromState

$rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams, error){
     $rootScope.lastState = { state: fromState, params: fromParams }
});

$rootScope.goBack = function() {
    $state.go($rootScope.lastState.state, $rootScope.lastState.params); //Don forget inject $state into your controller
}

#3

thanks , it works for me.
I your method to manage history my my self.