xxxxxxxxxx
<a [routerLink]="['/user/bob']" [relativeTo]="ActivatedRoute" [queryParams]="{debug: true}" fragment="education" [queryParams]="{debug: true}" queryParamsHandling="merge" [state]="{tracingId: 123}"></a>
constructor(private router:Router, private route: ActivatedRoute) { }
this.router.navigate([], {});
this.router.navigate(['x'], {});
this.router.navigate(['user', 'userId'], {});
this.router.navigate(['user/userId'], {});
this.route.snapshot.params['username'];
this.route.data.subscribe
this.route.data.subscribe
xxxxxxxxxx
import { Router } from '@angular/router';
constructor(
private router:Router
) { }
redirectFunction(){
this.router.navigate(['hello/redirect/pageURL'],{queryParams:{id:1234,name:"ash"}});
}
xxxxxxxxxx
import {Router} from '@angular/router'; // import router from angular router
export class Component{ // Example component..
constructor(private route:Router){}
go(){
this.route.navigate(['/page']); // navigate to other page
}
}
xxxxxxxxxx
// Here’s a basic example using the navigate method:
goPlaces() {
this.router.navigate(['/', 'page-name']);
}
/*
I hope it will help you.
Namaste
*/