bitwarden-estensione-browser/src/app/services/router.service.ts

26 lines
618 B
TypeScript
Raw Normal View History

2018-06-10 04:40:53 +02:00
import { Injectable } from '@angular/core';
import {
NavigationEnd,
Router,
} from '@angular/router';
@Injectable()
export class RouterService {
private previousUrl: string = undefined;
private currentUrl: string = undefined;
constructor(private router: Router) {
this.currentUrl = this.router.url;
router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
this.previousUrl = this.currentUrl;
this.currentUrl = event.url;
}
});
}
getPreviousUrl() {
return this.previousUrl;
}
}