I have this AppRoutingModule and HomeRoutingModule below. The first one contains some paths and imports the rest of paths from HomeRoutingModule. My problem is how can I get the departmentId inside HomeComponent? Actually my full path should be:
- 'domain:departments/:departmentId/profitability'
- 'domain:departments/:departmentId/loadFactor'
- ...
In each case I need to update only the departmentId in my url.
AppRoutingModule
const routes: Routes = [
{
path: 'home',
loadChildren: 'app/components/home/home.module#HomeModule',
data: { preload: true }
},
{ path: '', redirectTo: 'home/departments/group/profitability', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
HomeRoutingModule
const homeRoutes: Routes = [
{
path: 'departments',
component: HomeComponent,
children: [
{ path: ':departmentId/fabi', component: FabiComponent },
{ path: ':departmentId/loadFactor', component: LoadFactorComponent },
{ path: ':departmentId/otp', component: OtpComponent },
{ path: ':departmentId/profitability', component: ProfitabilityComponent },
{ path: ':departmentId/revenue', component: RevenueComponent },
{ path: ':departmentId/yield', component: YieldComponent }
]
},
{ path: '', redirectTo: 'home/departments/group/profitability', pathMatch: 'full' }
];