Skip to content

Instantly share code, notes, and snippets.

@cengkuru
Last active July 14, 2016 09:07
Show Gist options
  • Save cengkuru/b7c726df73549eef0393addea2fc3226 to your computer and use it in GitHub Desktop.
Save cengkuru/b7c726df73549eef0393addea2fc3226 to your computer and use it in GitHub Desktop.
track current and previous state
$rootScope.previousState;
$rootScope.currentState;
$rootScope.$on('$stateChangeSuccess', function(ev, to, toParams, from, fromParams) {
$rootScope.previousState = from.name;
$rootScope.currentState = to.name;
console.log('Previous state:'+$rootScope.previousState)
console.log('Current state:'+$rootScope.currentState)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment