Reputation: 3476
I have Routes defined in my app-routing.module.ts
const routes: Routes = [
.
.
.
{ path: 'home', component: HomeComponent, canActivate: [AuthGuard] }
];
Now in one of my Component, based on a condition I want to redirect to HomeComponent and pass extra parameters in the URL like /home?redirect=1
if( condition ) {
this.router.navigate(['/home?redirect=1'] );
} else {
this.router.navigate(['/home'] );
}
However it is not working. Could you please advice.
Upvotes: 0
Views: 263
Reputation: 38199
You should add params like that:
let params: { 'redirect': 1}
this.router.navigate(['/home'], {queryParams: params})
Upvotes: 3