angular how to get previous state

Solutions on MaxInterview for angular how to get previous state by the best coders in the world

showing results for - "angular how to get previous state"
Jayden
26 Feb 2019
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});