20 lines
599 B
TypeScript
20 lines
599 B
TypeScript
|
import {Injectable} from '@angular/core';
|
||
|
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||
|
import {Group} from './group';
|
||
|
import {Observable} from 'rxjs/internal/Observable';
|
||
|
import {GroupService} from './group.service';
|
||
|
|
||
|
@Injectable({
|
||
|
providedIn: 'root'
|
||
|
})
|
||
|
export class GroupResolver implements Resolve<Group> {
|
||
|
|
||
|
constructor(private ser: GroupService, private router: Router) {
|
||
|
}
|
||
|
|
||
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Group> {
|
||
|
const id = route.paramMap.get('id');
|
||
|
return this.ser.get(id);
|
||
|
}
|
||
|
}
|