Friday, 31 March 2023

angular - router add data to routes

 https://stackoverflow.com/questions/44864303/send-data-through-routing-paths-in-angular


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:


private route: ActivatedRoute

private router: Router

1) Required Routing Parameters:


enter image description here


2) Route Optional Parameters:


enter image description here


3) Route Query Parameters:


enter image description here


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

No comments:

Post a Comment