这是我的路线配置:
export const SchoolyearsRoutes: RouterConfig = [
{ path:'', terminal:true, redirectTo: '/schoolyears'},
{ path: 'schoolyears', component: SchoolyearsListComponent },
{ path: 'schoolyears/edit/:id', component: SchoolyearsEditComponent },
{ path: 'schoolyears/create', component: SchoolyearsCreateComponent }
但我希望将其作为:
export const SchoolyearsRoutes: RouterConfig = [
{ path:'', terminal:true, redirectTo: '/schoolyears'},
{ path: 'schoolyears', component: SchoolyearsListComponent },
{ path: 'edit/:id', component: SchoolyearsEditComponent },
{ path: 'create', component: SchoolyearsCreateComponent }
我希望编辑/创建路由在运行时隐式添加基本网址'schoolyears'。
如何在不重组我的组件的情况下实现这一目标?
更新
虽然我使用TypeScript但是我得到了一个运行时异常,它实际上应该在编译时发生:
browser_adapter.ts:84EXCEPTION: Error: Uncaught (in promise): TypeError: Cannot read property 'annotations' of undefined
答案 0 :(得分:2)
export const SchoolyearsRoutes: RouterConfig = [
{ path:'', terminal:true, redirectTo: '/schoolyears'},
{ path: 'schoolyears', component: SchoolyearsRootComponent, children: [
{ path: '', component: SchoolyearsListComponent },
{ path: 'edit/:id', component: SchoolyearsEditComponent },
{ path: 'create', component: SchoolyearsCreateComponent }
] }
]
不是解决你案件的事吗?