在Angular 6应用程序中,我有一条主路径和一条子路径(都是相同的组件)。
{
path: 'materiallist',
component: MaterialListComponent,
children: [
{ path: 'material/:materialNumber', component: MaterialListComponent }
]
},
我在MaterialListComponent
中,并导航至它起作用的子路由。
我得到一个这样的网址:
/materiallist/material/1234
注意:我仍然在MaterialListComponent
中。现在,当我尝试导航到相同的子路由,但又有另一个参数
this.router.navigate(['/materiallist/material', '9876']);
我得到一个例外:
core.js:1673 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'component' of null
TypeError: Cannot read property 'component' of null
at PreActivation.push../node_modules/@angular/router/fesm5/router.js.PreActivation.setupRouteGuards (router.js:2692)
at router.js:2655
at Array.forEach (<anonymous>)
at PreActivation.push../node_modules/@angular/router/fesm5/router.js.PreActivation.setupChildRouteGuards (router.js:2654)
at PreActivation.push../node_modules/@angular/router/fesm5/router.js.PreActivation.setupRouteGuards (router.js:2684)
at router.js:2655
at Array.forEach (<anonymous>)
at PreActivation.push../node_modules/@angular/router/fesm5/router.js.PreActivation.setupChildRouteGuards (router.js:2654)
at PreActivation.push../node_modules/@angular/router/fesm5/router.js.PreActivation.initialize (router.js:2627)
at MapSubscriber.project (router.js:3797)
at resolvePromise (zone.js:814)
at resolvePromise (zone.js:771)