Skip to main content
2 of 9
added 45 characters in body
Günter Zöchbauer
  • 661.5k
  • 235
  • 2.1k
  • 1.6k

update

import 'rxjs/add/operator/pairwise'; import {Router} from '@angular/router; export class AppComponent { constructor(private router: Router) { this.router.events.pairwise().subscribe((e) => { console.log(e); } }); } 

See also How to detect a route change in Angular?

original (super old)

Inject Router and subscribe to events and store them for later reference

constructor(private _router: Router) { this._router.subscribe(route => { this.nextRoute ... this.prevRoute ... }); 
Günter Zöchbauer
  • 661.5k
  • 235
  • 2.1k
  • 1.6k