Reputation: 837
I realize this is not a typical use case but I'm looking for a way to set Angular's Activated Route param. I want to be able to do something like the following in a component...
this.activatedRoute.params.subscribe(param => param.id = 'mySetId');
Then I might run some other methods on the component and then run getId() in a routing service to get the setId set from the component...
public getId(route: ActivatedRoute) {
let id;
route.params.subscribe(param => id = param.id);
return id;
}
getId() would then return 'mySetId'
Any ideas?
Upvotes: 1
Views: 1672
Reputation: 39482
I think the only way to set the ActivatedRoute
's params is by making the Router
navigate
to the same route, but with different params.
So basically if you want to set a new param
you can simply use the Router
and call the navigate
method on it and pass it a new param
.
The new param can then be obtained by again injecting the ActivatedRoute
as a dependency and then retrieving it by subscribe
ing to the params
Observable
.
Upvotes: 1