Reputation: 1420
In previous versions I've used $rootScope event:
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){}
Pretty straightforward approach.
But now I'm forced to use new $transition
service. So for generic info I'm writing:
$transitions.onStart({}, function(to, from){
console.log(from.router.globals.current.name);
console.log(to.router.globals.current.name);
});
from
is always empty and to.router.globals.current.name
is it really correct way to get a state
name now? :D
So, how I can get from
and to
names?
Upvotes: 0
Views: 228
Reputation: 3712
You should be able to get the from
and to
like this:
$transitions.onStart({}, function(transition){
console.log(transition.from());
console.log(transition.to());
});
Upvotes: 1