<!-- language-all: lang-ts -->

The `pairwise` operator allows to get the current together with the previous value

**update** &nbsp;

 import 'rxjs/add/operator/pairwise';
 import 'rxjs/add/operator/filter';
 import { Router, NavigationEnd } from '@angular/router';
 
 export class AppComponent {
 constructor(private router: Router) {
 this.router.events
 .filter(e => e instanceof NavigationEnd)
 .pairwise().subscribe((e) => {
 console.log(e);
 });
 }
 }
 
See also https://stackoverflow.com/questions/33520043/how-to-detect-route-change-in-angular-2/38080657#38080657

**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 ...
 });