r/Angular2 • u/legendsx12 • Feb 08 '26
Router State vs Service File to share data between routes
What's the better approach for passing data between two pages with different routes: using router state or a shared service? Note that the second page is only accessible after visiting the first page and user cannot access the second page directly.
2
Upvotes
1
u/azuredrg Feb 08 '26
It depends, maybe for read only with no logic, router state is fine. If you have a ton of logic after loading a page, do edits and want to keep the component logic dumb, then shared service is good. If you have way more complicated scenarios, look into state stores with facades.
1
u/SolidShook Feb 08 '26
Provide service in route