我正在使用Angular 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}});
}
答案 0 :(得分:1)
更改navigation()
this.router.navigate(['/survey', this.listedSurvey.surveyIdNum]);