brewman/overlord/src/app/role/role-resolver.service.ts

20 lines
591 B
TypeScript
Raw Normal View History

import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
import {Role} from './role';
import {Observable} from 'rxjs/internal/Observable';
import {RoleService} from './role.service';
@Injectable({
providedIn: 'root'
})
export class RoleResolver implements Resolve<Role> {
constructor(private ser: RoleService, private router: Router) {
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Role> {
const id = route.paramMap.get('id');
return this.ser.get(id);
}
}