0

Thats my route config:

export const SchoolyearsRoutes: RouterConfig = [
  { path:'', terminal:true, redirectTo: '/schoolyears'},
  { path: 'schoolyears',  component: SchoolyearsListComponent },
  { path: 'schoolyears/edit/:id', component: SchoolyearsEditComponent },
  { path: 'schoolyears/create', component: SchoolyearsCreateComponent }

but I want to have it as:

export const SchoolyearsRoutes: RouterConfig = [
  { path:'', terminal:true, redirectTo: '/schoolyears'},
  { path: 'schoolyears',  component: SchoolyearsListComponent },
  { path: 'edit/:id', component: SchoolyearsEditComponent },
  { path: 'create', component: SchoolyearsCreateComponent }

I want that edit/create route prepend the base url 'schoolyears' implicitly during runtime.

How can I achieve this without restructure my components?

UPDATE

Although I use TypeScript I get a runtime exception which should actually happen at compile time:

browser_adapter.ts:84EXCEPTION: Error: Uncaught (in promise): TypeError: Cannot read property 'annotations' of undefined
4

1 回答 1

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 }
  ] }
]

不是可以解决您的问题吗?

于 2016-06-27T21:41:44.393 回答