2018-05-25 13:49:00 +00:00
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
2020-05-11 20:01:21 +00:00
|
|
|
import {Role} from './role';
|
2018-05-25 13:49:00 +00:00
|
|
|
import {Observable} from 'rxjs/internal/Observable';
|
2020-05-11 20:01:21 +00:00
|
|
|
import {RoleService} from './role.service';
|
2018-05-25 13:49:00 +00:00
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
2020-05-11 20:01:21 +00:00
|
|
|
export class RoleResolver implements Resolve<Role> {
|
2018-05-25 13:49:00 +00:00
|
|
|
|
2020-05-11 20:01:21 +00:00
|
|
|
constructor(private ser: RoleService, private router: Router) {
|
2018-05-25 13:49:00 +00:00
|
|
|
}
|
|
|
|
|
2020-05-11 20:01:21 +00:00
|
|
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Role> {
|
2018-05-25 13:49:00 +00:00
|
|
|
const id = route.paramMap.get('id');
|
|
|
|
return this.ser.get(id);
|
|
|
|
}
|
|
|
|
}
|