2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { CanDeactivate, Router} from '@angular/router';
|
|
|
|
import {Observable} from 'rxjs/Observable';
|
|
|
|
|
|
|
|
@Injectable() // do not forget to register this class as a provider
|
|
|
|
export class PreviousRouteRecorder implements CanDeactivate<any> {
|
|
|
|
constructor(private router: Router) {
|
|
|
|
}
|
|
|
|
canDeactivate(component: any): Observable<boolean> | boolean {
|
|
|
|
if (typeof localStorage !== 'undefined') {
|
2019-02-14 11:44:30 +01:00
|
|
|
//console.log("In PreviousRouteRecorder : "+this.router.url );
|
2017-12-19 13:53:46 +01:00
|
|
|
localStorage.setItem('previousRoute', this.router.url);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|