openaire-library/utils/piwik/previousRouteRecorder.guard.ts

21 lines
724 B
TypeScript
Raw Normal View History

import { Injectable } from '@angular/core';
2023-08-01 13:29:27 +02:00
import { Router } from '@angular/router';
import {Observable} from 'rxjs';
import {properties} from "../../../../environments/environment";
@Injectable({
providedIn: 'root'
}) // do not forget to register this class as a provider
2023-08-01 13:29:27 +02:00
export class PreviousRouteRecorder {
constructor(private router: Router) {
}
canDeactivate(component: any): Observable<boolean> | boolean {
if (typeof localStorage !== 'undefined') {
// console.log("In PreviousRouteRecorder : " + properties.domain +properties.baseLink + this.router.url );
localStorage.setItem('previousRoute', properties.domain + properties.baseLink + this.router.url);
}
return true;
}
}