如何在 angular 中传递额外的路由参数?

How to pass additional route parameter in angular?

我正在开发 Angular 6 应用程序并在应用程序根级别配置路由调查,然后 :id 获取调查详细信息页面,我正在尝试使用 [=15= 从组件导航]

 this.router.navigate(['/survey'], this.listedSurvey.surveyIdNum);

但我认为我在路由器导航中遗漏了一些东西,因为我无法这样做。

应用路线

const routes: Routes = [
{ path:'welcome', component:WelcomeComponent },
{ path:'', redirectTo: 'welcome', pathMatch:'full'},
{ path:'survey', loadChildren: '../survey/survey.module#SurveyModule' },
{ path:'**', component:PageNotFoundComponent}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [
 RouterModule
 ]
 })

 export class AppRoutingModule { }

调查模块

const routes: Routes = [
{ 
    path:'', 
    component:SurveyComponent,
},
{
    path:':id',
    component: SurveyFormComponent
 }
];

@NgModule({
 imports:[
     RouterModule.forChild(routes)
 ],
 exports:[]
})
 export class SurveyRouting{
}

组件

 private handleSelectedSurvey(dataItem:any){
   this.listedSurvey = dataItem;
   const a:number = 2;
   //this.router.navigate(['/survey'], this.listedSurvey.surveyIdNum);
   this.router.navigate(['/survey'],{queryParams:{id:a}}); 
 }

更改导航() this.router.navigate(['/survey', this.listedSurvey.surveyIdNum]);

参考:https://angular.io/api/router/Router#navigate