我正在尝试制作一个可以提供每条路线的全局解析器……
this.activatedRoute.data
=>
{
global: {...}
route: {...}
}
这就是我正在尝试的
const routes: Routes = [
{
path: '',
resolve: { globalResolve: globalResolverService },
children: [
{ path: '', component: HomeComponent, resolve: { home: ViewHomeResolver } },
{ path: 'getting-started', component: GettingStartedComponent },
{ path: 'expert/:slug', component: ProfileComponent, resolve: { profile: ProfileResolver } },
{ path: 'loan-types', component: Loantype2Component, resolve: { grid: Loan2Resolver } },
{ path: 'loan-types/:loan', component: LoanCategoryDetailsComponent, resolve: { loanDetails: LoanDetailsResolver } },
]},
];
上述结果仅对homeComponent
产生期望的结果。
答案 0 :(得分:1)
您的this.activatedRoute.data
表示您正在访问自己的路由数据范围
要访问父数据,请使用this.activatedRoute.parent.data