Angular2 v3-Komponente-router: TypeError: Cannot read property 'split' von undefined
Ich vor kurzem schaltete mein angular2-app von RC-router der v3 router. Ich bin immer der Fehler
TypeError: Cannot read property 'split' of undefined
at match`.
Nach dem aktivieren der Ablaufverfolgung auf dem router zu bekommen, die debug-Ausgabe, es sieht aus wie die Quelle der Fehler ist aus dem router:
NavigationError {id: 2, url: "/my/workspace/1252407935628215305/projects", error: TypeError: Cannot read property 'split' of undefined
at match - common_router_providers.js:28 NavigationError {id: 2, url: "/my/workspace/1252407935628215305/projects", error: TypeError: Cannot read property 'split' of undefined
at match (http://localhost:8080/vendor.6a9d…}error: TypeError: Cannot read property 'split' of undefined
at match (http://localhost:8080/vendor.6a9dd9122cbbc98aa93a.js:74100:22)
at matchPathsWithParamsAgainstRoute (http://localhost:8080/vendor.6a9dd9122cbbc98aa93a.js:74073:19)
at expandPathsWithParamsAgainstRoute (http://localhost:8080/vendor.6a9dd9122cbbc98aa93a.js:74038:17)
at expandPathsWithParams (http://localhost:8080/vendor.6a9dd9122cbbc98aa93a.js:74020:21)
at matchPathsWithParamsAgainstRoute (http://localhost:8080/vendor.6a9dd9122cbbc98aa93a.js:74085:23)
at expandPathsWithParamsAgainstRoute (http://localhost:8080/vendor.6a9dd9122cbbc98aa93a.js:74038:17)
at expandPathsWithParams (http://localhost:8080/vendor.6a9dd9122cbbc98aa93a.js:74020:21)
at expandSegment (http://localhost:8080/vendor.6a9dd9122cbbc98aa93a.js:74010:17)
at http://localhost:8080/vendor.6a9dd9122cbbc98aa93a.js:74014:84
at http://localhost:8080/vendor.6a9dd9122cbbc98aa93a.js:74367:41message: "Cannot read property 'split' of undefined"stack: (...)get stack: stack()set stack: stack()__proto__: Errorid: 2url: "/my/workspace/1252407935628215305/projects"__proto__: Object
Dies ist meine router-config-setup:
export const routes: RouterConfig = [
...MyAppRoutes,
{ path: 'login', component: LoginComponent},
{ path: 'signup', component: SignUpComponent},
{ path: 'join', component: JoinComponent},
{ path: 'version', component: VersionComponent},
{ path: '', redirectTo: 'login', terminal: true},
];
export const APP_ROUTER_PROVIDERS = [
provideRouter(routes, {enableTracing: true})
];
MyAppRoutes:
export const MyAppRoutes: RouterConfig = [
{ path: 'my',
component: MyAppComponent,
children: [
{path: 'dashboard', component: DashboardComponent},
{path: 'profile', component: EditProfileComponent},
{path: 'password', component: ChangePasswordComponent},
{path: '', redirectTo: 'dashboard', terminal: true},
...WorkspaceRoutes,
]
},
];
WorkspaceRoutes
export const WorkspaceRoutes: RouterConfig = [
{path: 'workspace/:id', component: WorkspaceRootComponent},
{children: [
{path: 'projects', component: WorkspaceDashboardComponent},
{path: 'newproject', component: ProjectNewComponent},
{path: '', redirectTo: 'projects', terminal: true},
]}
];
Routing funktioniert gut auf den oberen zwei Ebenen (app Routen und MyAppRoutes). Aber versuchen, zu navigieren, zu jeder route wie /my/workspace/1234/projects
schlägt mit der oben genannten Fehler. Das gleiche setup mit der Angular2 beta und v2 Router.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ich habe herausgefunden, was Los war. Im Fall, jemand hat ein ähnliches Problem, das problem war in diesem Fall in WorkspaceRoutes.
Sollte
Die Kinder Artikel von WorkspaceRootComponent war nicht unter diesem posten, sondern auf der gleichen Ebene.