import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { AgentService } from '../service/agent.service';
import { Observable } from 'rxjs';

@Injectable({ providedIn: 'root' })
export class AgentDetailResolver implements Resolve<any> {
    
  constructor(private service: AgentService) {}

  resolve(
    route: ActivatedRouteSnapshot,
    state: RouterStateSnapshot
  ): Observable<any>|Promise<any>|any {

    let code = route.paramMap.get('code');

    return this.service.getResult(code);
  }
}
