STEVER STEVER - 5 months ago 70
Javascript Question

How to get toState param with $transitions service? (new ui-router)

I'm using ui-router 1.0.0-alpha.3.
Old events are deprecated there.

so I'm trying to convert

$rootScope.$on('$stateChangeStart', (event, toState) => {
//...
});


to new way of doing things with $transitions.onStart hook -

$transitions.onStart( {}, function($state, $transition$) {
//...
});


where could I get toState param in this case?

Answer

Use $transition$.$to() for it.

$transitions.onStart( {}, function($transition$) {
    //stateTo === $transition$.$to();
});
Comments