2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { CanDeactivate, Router} from '@angular/router';
|
2019-06-03 15:20:36 +02:00
|
|
|
import {Observable} from 'rxjs';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@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-03-04 14:23:01 +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;
|
|
|
|
}
|
|
|
|
}
|