Answers for "angular how to check previous route"

3

angular how to check previous route

//Update angular 6+
//The events.filter gives error because filter is not part of events, so change the code to

import { filter, pairwise } from 'rxjs/operators';

this.router.events
.pipe(filter((evt: any) => evt instanceof RoutesRecognized), pairwise())
.subscribe((events: RoutesRecognized[]) => {
  console.log('previous url', events[0].urlAfterRedirects);
  console.log('current url', events[1].urlAfterRedirects);
});
Posted by: Guest on December-12-2020

Code answers related to "angular how to check previous route"

Code answers related to "Javascript"

Browse Popular Code Answers by Language