1import { Router } from '@angular/router';
2
3constructor(
4 private router:Router
5 ) { }
6
7redirectFunction(){
8 this.router.navigate(['hello/redirect/pageURL'],{queryParams:{id:1234,name:"ash"}});
9}
1import {Router} from '@angular/router'; // import router from angular router
2
3export class Component{ // Example component..
4 constructor(private route:Router){}
5
6 go(){
7 this.route.navigate(['/page']); // navigate to other page
8 }
9}
1// Here’s a basic example using the navigate method:
2
3goPlaces() {
4 this.router.navigate(['/', 'page-name']);
5}
6
7/*
8I hope it will help you.
9Namaste
10*/
1
2 const appRoutes: Routes = [
3 { path: 'crisis-center/:param1', component: CrisisListComponent },
4 { path: 'hero/:param2', component: HeroDetailComponent },
5];
6
7@NgModule({
8 imports: [
9 RouterModule.forRoot(
10 appRoutes,
11 { enableTracing: true } // <-- debugging purposes only
12 )
13 // other imports here
14 ],
15 ...
16})
17export class AppModule { }
18