You can listen to your controller $destroy $scope event
var UserCtrl = function ($scope) { $scope.$on('$destroy', function() {
And for some reference, when the controller receives the instance and is destroyed on ui-router, see this question
EDIT 1: If you want to access the $ state parameters, you can listen to the events of $stateChangeStart or $stateChangeSuccess and do something like this
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState,fromParams) { if(fromState.name == 'yourstate'){
EDIT 2: The reason you cannot use onExit is because the state was already changed by the time this method was called. However, this is fixed in the next major version (1.0) by adding an injection service called $transition$ , which will provide access to state parameters, you can learn more about this here
source share