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';
|
2020-09-18 09:57:42 +02:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2020-08-12 17:16:09 +02:00
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
}) // do not forget to register this class as a provider
|
2017-12-19 13:53:46 +01:00
|
|
|
export class PreviousRouteRecorder implements CanDeactivate<any> {
|
|
|
|
constructor(private router: Router) {
|
|
|
|
}
|
|
|
|
canDeactivate(component: any): Observable<boolean> | boolean {
|
|
|
|
if (typeof localStorage !== 'undefined') {
|
2020-09-18 15:26:15 +02:00
|
|
|
console.log("In PreviousRouteRecorder : " + properties.domain +properties.baseLink + this.router.url );
|
2020-09-18 12:10:18 +02:00
|
|
|
localStorage.setItem('previousRoute', properties.domain + properties.baseLink + this.router.url);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|