I know there is an option to preserve a query param if the navigation is happening directly with routerLink or router. navigate method (through {queryParamsHandling: 'preserve'}) but I need the following: When the queryParam is set, I want to use it throughout the entire application. Is it possible to achieve it?
I have a webpage with a specific router configuration:
{path: 'transport', component: TransportComponent},
{path: 'events/:id', component: EventsComponent},
{path: 'pages/:page', component: PagesComponent}
This is just a part of it, let's say regular routes.
My problem is that these links can be opened in 2 ways:
- They can be opened without a location in which case it would be localhost:4200/transport
- They can be opened with the location in which case it would be localhost:4200/transport?locationName
Location can be selected on home page.
So my idea was to save the location name in queryParam but I struggle to find a way to preserve on every route change