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"; import { any } from "../Interfaces/any"; import { DyCommon } from "../Common"; @Injectable() export class SignResolver 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): any | Observable | Promise { console.log(route); var promise = new Promise((fres, rej) => { this.http.get(`bbapi/setup/signSetup`).takeUntil(this.ngUnsubscribe).subscribe(res => { var mod: any = res; //this.checkDefaults(mod); //ContactResolver.setupContact(mod); // res.contact.recordTypeId = res.contact.recordTypeId.split(","); fres(mod) }); }) return promise; } }