延迟加载模块与路线数据

时间:2020-06-22 20:33:31

标签: angular angular-routing angular-lazyloading

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']
}

0 个答案:

没有答案
相关问题