Angular 7, if you want to subscribe to router
import { Router, NavigationEnd } from '@angular/router'; import { filter } from 'rxjs/operators'; constructor( private router: Router ) { router.events.pipe( filter(event => event instanceof NavigationEnd) ).subscribe((event: NavigationEnd) => { console.log(event.url); }); } import { Router, NavigationEnd } from '@angular/router'; import { filter } from 'rxjs/operators'; constructor( private router: Router ) { router.events.pipe( filter(event => event instanceof NavigationEnd) ).subscribe((event: NavigationEnd) => { console.log(event.url); }); }