While transitioning, I need the ability to modify parameter values. After researching the documentation, I discovered a method called `params('to')` that allows accessing target state's parameters. This is how it looks in my code:
$transitions.onStart({ from: 'state3', to: 'state1' }, function ($transition$) {
var params = $transition$.params('to');
if(someCondition){
params.success = true;
}
$transition$.params['to'] = params;
});
The definition of my state1
is as follows:
$stateProvider
.state('state1', {
url: '/',
params: {
success: false,
},
...
However, when I execute the transition with the above code, the value of my success
parameter always remains as the default value (false
).
My question is: Can parameter values be changed during a transition?
Context: I have two buttons for transitioning from state3
to state1
. I can control one button from my $scope
, but the other is a breadcrumb link outside of the $scope
. I thought about using the $transitions
hook to check certain conditions and set success
accordingly.
I came across an answer suggesting triggering a new $state.go with new parameters, but I find it cumbersome and hacky. I believe there must be a simpler and cleaner way to achieve this.