【发布时间】:2020-12-30 13:45:03
【问题描述】:
路由数组
const routes: Routes = [
...
{path:'exam-list',component: ExamListComponent},
{path:'exam-panel/:Id',component: ExamPanelComponent}
..
];
数组导入
@NgModule({
imports: [RouterModule.forRoot(routes)],
点击事件
onSelect(examdetails)
{
this.router.navigate(['exam-panel',examdetails.Id])
}
点击事件 onselect()
我收到了这个错误 错误:未捕获(承诺中):错误:无法匹配任何路由。 URL 段:'exam-panel' 带参数 当我使用 routerLink 时,它可以正常工作,但是单击事件无法与 router.navigate 一起使用
当我使用 [routerLink]="['/exam-panel/',examdetails.Id]" 时,它正在工作,但是当我使用 "router.navigate" 时,它使用参数导航第一个路由考试面板好的,然后自动路由到首页
【问题讨论】:
标签: angular angular-routing angular10