I have a route defined like this in the routing module:
{ path: 'warning/:type', component: WarningPageComponent }
When the app wants to navigate to the warning page this call is made:
const navigationExtras: NavigationExtras = {
queryParamsHandling: 'preserve',
queryParams: { errorCode: '12345'}
};
return this.router.navigate(['/warning/default'],navigationExtras);
In the WarningPageComponent
the parameters are read like this ngOnInit()
:
const params = this.route.snapshot.paramMap;
console.log('ERR warning page' + JSON.stringify(params));
const errorCode = params.get('errorCode') ?? undefined;
const type = params.get('type') ?? undefined;
The problem is now that only the type
is present in the paramMap
but not the errorCode
. What is wrong here? I also tried with queryParamsHandling: 'preserve'
Angular 8.2.14
I found no solution in: