我在下面有这个AppRoutingModule和HomeRoutingModule。第一个包含一些路径并从HomeRoutingModule导入其余路径。 我的问题是如何在HomeComponent中获得departmentId? 其实我的完整路径应该是:
在每种情况下,我只需要更新我的网址中的departmentId。
AppRoutingModule
GO_BACK(6)
HomeRoutingModule
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 }
];
答案 0 :(得分:0)
你必须在两个路由文件中都这样写。 在AppRoutingModule中,写下"部门"而不是回家。
const routes: Routes = [
{
path: 'departments',
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: '',
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' }
];
我希望它对你有用。
由于