"child"路由路径应包括父路由路径

"child" Route path should include parent route path

那是我的路线配置:

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 }

我希望 edit/create 路由在运行时隐式地预先添加基础 url 'schoolyears'。

如何在不重组我的组件的情况下实现这一点?

更新

虽然我使用 TypeScript,但我得到了一个运行时异常,它实际上应该在编译时发生:

browser_adapter.ts:84EXCEPTION: Error: Uncaught (in promise): TypeError: Cannot read property 'annotations' of undefined
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 }
  ] }
]

这不是解决你的问题的东西吗?