Skip to main content
4 of 4
typescript code highlight
Pini Cheyni
  • 5.5k
  • 2
  • 45
  • 58

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); }); } 
Druta Ruslan
  • 7.4k
  • 2
  • 31
  • 40