Fisierul de routing.ts contine calea de baza extinsa cu 2 parametri (policeReportId si source):
{
path: Path.POLICE_REPORT_DETAILS + '/:policeReportId',
component: PoliceReportDetailsPage,
canActivate: [Guard]
},
{
path: Path.POLICE_REPORT_DETAILS + '/:policeReportId/:source',
component: PoliceReportDetailsPage,
canActivate: [Guard]
},
In componenta corespunzatoare caii se cauta de parametri:
constructor(private route: ActivatedRoute) {
}
ngOnInit(): void {
if (isNotNullOrUndefined(this.route.snapshot.paramMap?.get('source'))) {
switch (this.route.snapshot.paramMap.get('source')) {
case RedirectSource.DECISIONS:
// do something
}
}
}
In componenta care face redirectarea se specifica parametrul suplimentar:
refreshPage(path: string): void {
path = path + '/' + RedirectSource.DECISIONS;
this.router.navigateByUrl('/', {skipLocationChange: true}).then(() =>
this.router.navigate([path]));
}
P.S. a nu se uita:
<router-outlet></router-outlet>
Niciun comentariu:
Trimiteți un comentariu