import { Router, NavigationEnd } from '@angular/router';
constructor(
private router: Router
) {
// 前のページURLを取得する
this.currentUrl = this.router.url;
router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
this.previousUrl = this.currentUrl;
this.currentUrl = event.url;
}
});
}
これで this.previousUrl に前ページURLが入ります。