I am working on setting up a redirect in Angular 6
The process for the redirect is quite simple as outlined below:
Obtain destination URL from parameters:
this.returnUrl = this.route.snapshot.queryParams['route'] || '/';
Perform Redirect
if (this.returnUrl) {
this.router.navigate([this.returnUrl]);
} else {
this.router.navigate(['/']);
}
The issue arises when the URL contains parameters, such as:
Redirect URL being
'/survey/finish?key=7krmpqpC0P&mind=Akkoord&companyNumber=%5B%5BQ2%5D'
This results in an error message
Error: Cannot match any routes. URL Segment: 'survey/finish%3Fkey%3D7krmpqpC0P&mind%3DAkkoord&companyNumber%3D%255B%255BQ2%255D'
How do I correctly redirect to the provided URL string?
For example,
http://localhost:4200/survey/finish?key=7krmpqpC0P&mind=Akkoord&companyNumber=%5B%5BQ2%5D
My route appears as follows
{
path: 'survey/finish',
component: CallbackComponent,
canActivate: [AuthGuard]
}