Is there anyway to send data as parameter with router.navigate? I mean, something like this example, as you can see the route has a data parameter, but doing this it's not working:
this.router.navigate(["heroes"], {some-data: "othrData"})
because some-data is not a valid parameter. How can I do that? I don't want to send the parameter with queryParams.
There is a lot of confusion on this topic because there are so many different ways to do it.
Here are the appropriate types used in the following screen shots:
1) Required Routing Parameters:
2) Route Optional Parameters:
3) Route Query Parameters:
4) You can use a service to pass data from one component to another without using route parameters at all.
For an example see: https://blogs.msmvps.com/deborahk/build-a-simple-angular-service-to-share-data/
I have a plunker of this here: https://plnkr.co/edit/KT4JLmpcwGBM2xdZQeI9?p=preview
Best I found on internet for this is ngx-navigation-with-data. It is very simple and good for navigation the data from one component to another component. You have to just import the component class and use it in very simple way. Suppose you have home and about component and want to send data then
HOME COMPONENT
ABOUT COMPONENT
For any query follow https://www.npmjs.com/package/ngx-navigation-with-data
Comment down for help.
You can use this. Angular2+/4/5 - navigate with data https://github.com/Hipparch/Angular2-navigate-with-data