Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI Router: get params of "to" and "from" state with $transitions service

I'm trying to use $transitions service instead of $stateParams like there for listening on state changing, but can't get state params. I'm using property of StateObject, but instead of getting for example {id: 123}, i got {id: e}, where e is a object in which i can't find a value. Anybody help with this ?

$transitions.onStart({ }, function(trans) {
    console.log(trans.$from().params);
}

I noticed that trans.params() return "to" state params.

like image 615
marioosh Avatar asked Jul 31 '17 09:07

marioosh


1 Answers

trans.$from().params will get you from state parameters declaration.

trans.params('from') will get you their actual values


Probably what you need is:

$transitions.onStart({ }, function(trans) {
    console.log(trans.params('from'));
}

Please refer to documentation here

State params https://ui-router.github.io/ng1/docs/latest/interfaces/state.statedeclaration.html#params

Transition params https://ui-router.github.io/ng1/docs/latest/classes/transition.transition-1.html#params

like image 152
Pavel Bely Avatar answered Oct 15 '22 16:10

Pavel Bely