1//Update angular 6+
2//The events.filter gives error because filter is not part of events, so change the code to
3
4import { filter, pairwise } from 'rxjs/operators';
5
6this.router.events
7.pipe(filter((evt: any) => evt instanceof RoutesRecognized), pairwise())
8.subscribe((events: RoutesRecognized[]) => {
9 console.log('previous url', events[0].urlAfterRedirects);
10 console.log('current url', events[1].urlAfterRedirects);
11});