I'm trying to kickstart my app by providing it a client id by using routes:
www.mysite.com/11298/[any page]
11298 would be the client id and user can navigate to any page under that route. So basically the clientId will always be in the address, whatever the subroute is. Here's the router config:
export const ROUTES: Routes = [
{
path: ':clientId',
canActivate: [InitializeGuard],
component: StartPageComponent,
children: [
{ path: '', redirectTo: 'page1', pathMatch: 'full' },
{ path: 'page1', component: Page1Component },
{ path: 'page2', component: Page2Component },
{ path: 'page3', component: Page3Component },
{ path: 'page4', component: Page4Component },
],
},
];
I'm currently using InitializeGuard on the routes and it would be ideal if I could access the :clientId from that service. Is this possible? If the user would always navigate to www.mysite.com/14918, I could just read the id in StartPageComponent, but I can't know which route the user will go to.
How could I read the :clientId where ever the user goes to without rewriting some subscription code into every component in my app? It would be really cool if I could pass the :clientId to InitializeGuard for init and it would take care of it non-intrusively.
If it's not possible, what would be the another way of doing this? I'm thinking about a shared service for init, but I would still have to do the init in all of the PageXComponents, which doesn't sound good.
If this doesn't work as a strategy, what would be a good strategy to pass a site-wide clientId to every route upon navigation?