app-routing.module.ts
{
path: 'billing',
loadChildren: () => import('./billing/billing.module').then(m => m.BillingModule)
},
billing-routing.module.ts
const routes: Routes = [
{
path: '',
children: [
{ path: 'buy/:product-hint', component: BuyComponent, data: { header: 'buy' } }
]
}
为什么必须尝试访问路线data
? 3个嵌套的firstChild
来获取它。
this.router.events.subscribe(e => {
const data = e.state.root.firstChild.firstChild.firstChild.data['header']
}