我有一个带有四列的板,每列填充有n个项目,当我单击其中一个项目时,应该加载sidenav中的详细信息部分,由于某些原因,我仍然可以得到为什么...每次尝试在项目中打开详细信息部分时,都会收到此错误Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'HyPE4PM/2/details/5413869/DetaILS'
。现在,我的app.module
正在延迟加载backlog.module
,而积压模块正在延迟加载board.module
作为子级,而board.module
正在延迟加载details.module
小时候。
应用程序路由模块
export const routes: Routes = [
{
path: 'HyPE4PM',loadChildren: () => import('./modules/lazy/backlog.module').then((mod) => mod.BacklogModule)
},{
path: 'Error',loadChildren: () => import('./modules/lazy/error-site.module').then((mod) => mod.ErrorSiteModule)
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],exports: [RouterModule],providers: []
})
backlog-routing.module
/**
* define the routes for the BacklogComponent module
*/
const routes: Routes = [
{
path: '',component: BacklogComponent,children: [
{
path: '2',loadChildren: () => import('../lazy/boards-modules/taskboard.module').then((mod) => mod.Taskboardmodule)
},]
}
];
/**
* define the routing for the BacklogComponent module
*/
@NgModule({
imports: [RouterModule.forChild(routes)],exports: [RouterModule]
})
board-routing.module
const routes: Routes = [
{
path: '',component: TaksboardComponent,children: [
{ path: 'details/:id',redirectTo: 'details/:id/DetaILS',pathMatch: 'full' },{
path: 'details/:id/:detailsSection',loadChildren: () => import('../lazy/backlog-item-details.module').then((mod) => mod.BacklogItemDetailsModule),outlet: 'rightSidenav',data: { preload: true,delay: 2500 }
}
]
}
];
/**
* define the routing for the BacklogComponent module
*/
@NgModule({
imports: [RouterModule.forChild(routes)],exports: [RouterModule]
})
然后,我使用router.navigate
进入所选项目的详细信息:
public selectItem(event: MouseEvent,position: DetailSections) {
this.log.trace(`selectItem() in backlog item comp. id: ${this.backlogItem.id}`);
this.eventService.hideBoardCreator.emit();
// as the click to these events are bound on the DOM on childs of the click to the details -> we need to stop the event here
// if TS on other card is shown,it needs to be hidden
event.stopPropagation();
// save selection into store
this.store.dispatch(new BacklogItemSelected(this.backlogItem));
// show the details section
this.router.navigate([`/HyPE4PM/${this.configService.boardtype}/details`,this.backlogItem.id,DetailSections[position]]);
}
在这里,我分享了一个错误stackblitz ,如您在示例中所看到的,如果尝试去hype/2/details
路线,则会出错。