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// Place import at the top
2import { Router,NavigationStart} from '@angular/router';
3
4//Place the code below inside your class
5constructor(private router: Router){}
6
7ngOnInit(){
8 this.router.events.subscribe(event =>{
9 if (event instanceof NavigationStart){
10
11 }
12 })
13}