如何通过附加路由参数的角度?

问题描述 投票:0回答:1

我的工作角6应用程序并正在对应用程序根级别,然后配置路由调查:ID把它调查详细信息页面,我试图用从零部件导航

 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}}); 
 }
angular6 angular-routing
1个回答
1
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.