import { Component, OnInit } from '@angular/core'; import { Location } from '@angular/common' import { Router, ActivatedRoute } from '@angular/router'; @Component({ selector: 'app-unavailable', templateUrl: './unavailable.component.html' }) export class UnavailableComponent implements OnInit { targetRoute = ''; constructor( private location: Location, private router: Router, private route: ActivatedRoute) { } ngOnInit(): void { this.route.queryParams.subscribe({ next: (params) => { if (params[ 'target' ]) { this.targetRoute = params[ 'target' ]; this.router.navigate([], { queryParams: { target: null }, queryParamsHandling: 'merge', skipLocationChange: true }); } } }); } retry() { if (!this.targetRoute || this.targetRoute === "unavailable" || this.targetRoute === "/unavailable") { this.location.back; } else { this.router.navigate([ this.targetRoute ]); } } }