I want to navigate from one component to another component and some data to it.
Here is the code:
this.router.navigate(['some-component', { name: 'Some Name' }]);
In SomeComponent I am catching route params like this:
this.route.params.subscribe(params => {
//assign it to some component member, like
this.name = (JSON.parse(params))['name'];
});
This works, but it does not give me the confidence, after page gets navigated to SomeComponent view, the url looks bad and it does not keep the state after page reload.
I would like to avoid route parameters.
What would be correct way to navigate to SomeComponent and send it value that will be used inside and binded to this.name for example.
These two components are not in child/parent relationship.
BehaviorSubjectinstead ofSubject.