Project

General

Profile

1

    
2
import { Injectable } from '@angular/core';
3
import { CanDeactivate, Router} from '@angular/router';
4
import {Observable}       from 'rxjs';
5
import {properties} from "../../../../environments/environment";
6

    
7
@Injectable({
8
  providedIn: 'root'
9
}) // do not forget to register this class as a provider
10
export class PreviousRouteRecorder implements CanDeactivate<any> {
11
  constructor(private router: Router) {
12
  }
13
  canDeactivate(component: any): Observable<boolean> | boolean {
14
    if (typeof localStorage !== 'undefined') {
15
      // console.log("In PreviousRouteRecorder : " + properties.domain +properties.baseLink + this.router.url );
16
      localStorage.setItem('previousRoute', properties.domain + properties.baseLink + this.router.url);
17
    }
18
    return true;
19
  }
20
}
(3-3/3)