const appRoutes: Routes = [
{ path: 'parent', component: parentComp, data: { foo: 'parent data' }, children: [
{ path: 'child1', component: childComp1, data: { bar: 'child data 1' },
{ path: 'child2', component: childComp2, data: { bar: 'child data 2' }
]}
];
如果我导航到/parent/child2
,然后查看parentComp
中的ActivatedRoute
,则定义了data.foo
,但没有定义data.bar
.我可以访问所有子元素的数组,但我不知道哪个子元素被激活了.
如何从父路由的组件访问激活的子路由的数据?