|
@@ -1,8 +1,9 @@
|
1
|
1
|
import { HttpClient } from '@angular/common/http';
|
2
|
|
-import { Component, OnInit } from '@angular/core';
|
|
2
|
+import { Component, Injectable, OnInit } from '@angular/core';
|
3
|
3
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
4
|
|
-import { ActivatedRoute } from '@angular/router';
|
|
4
|
+import { ActivatedRoute, Resolve } from '@angular/router';
|
5
|
5
|
import { Observable } from 'rxjs';
|
|
6
|
+import { map, switchMap } from 'rxjs/operators';
|
6
|
7
|
import { AppBreadcrumbService } from 'src/app/app.breadcrumb.service';
|
7
|
8
|
import { Candidate } from 'src/app/shared/models/candidate';
|
8
|
9
|
import { CandidateService } from 'src/app/shared/services/candidate.service';
|
|
@@ -70,3 +71,14 @@ export class CandidatDetailComponent implements OnInit {
|
70
|
71
|
}
|
71
|
72
|
|
72
|
73
|
}
|
|
74
|
+
|
|
75
|
+@Injectable()
|
|
76
|
+export class CandidatDetailResolver implements Resolve<Candidate> {
|
|
77
|
+ constructor(public service: CandidateService, private route: ActivatedRoute) {}
|
|
78
|
+ resolve(): Observable<Candidate> {
|
|
79
|
+ return this.route.queryParams.pipe(
|
|
80
|
+ map(params => params['candidatId']),
|
|
81
|
+ switchMap(candidatId => this.service.candidatGetById(candidatId)),
|
|
82
|
+ );
|
|
83
|
+ }
|
|
84
|
+}
|