【发布时间】:2019-03-07 04:13:29
【问题描述】:
我需要编写一个从 routeConfigs 获取对象的组件。像这样:
route.routeConfig.data['info']
哪里路由:ActivatedRoute 和这样配置的路由:
const routes: Routes =
[{
path: 'people', data: { info: 'Parent' },
children: [
{ path: '', component: Component1, data: { info: 'Child1' } },
{ path: ':id', component: Component1, data: { info: 'Child2' } },
{ path: 'new', component: Component1, data: { info: 'Child3' } }
]
}];
所以我需要一个函数返回一个对象/字符串列表,这些对象/字符串位于当前路由和每个父路由的配置数据中。
对于上述值,当我通过路由 /people/new 将组件放入组件时
结果我必须有:["Parent", "Child3"]
请帮助我,强大的所有人。
【问题讨论】:
标签: angular typescript routing angular2-routing