import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from "@angular/Router" import { Injectable,Inject, OnDestroy } from "@angular/core"; import { HttpClient } from "@angular/Common/http"; import { Observable, Subject } from "rxjs"; @Injectable() export class BankAccountRegisterResolver implements Resolve,OnDestroy{ private http: HttpClient; constructor(@Inject(HttpClient) _http: HttpClient) { this.http = _http; } private ngUnsubscribe: Subject = new Subject(); ngOnDestroy(): any { this.ngUnsubscribe.next(); this.ngUnsubscribe.complete(); } resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): orderViewModel | Observable | Promise { console.log(route); var promise = new Promise((fres, rej) => { this.http.get(`/dyapi/BankAccountRegister/GetBankAccountRegisterInfo/${route.params["id"]}`).takeUntil(this.ngUnsubscribe).subscribe(res => { var mod: orderViewModel = res; fres(mod) }); }) return promise; } }