import { Injectable } from "@angular/core" ; import { ActivatedRouteSnapshot , Resolve , RouterStateSnapshot } from "@angular/router" ; import { Course } from "../model/course" ; import { Observable } from "rxjs" ; import { CoursesService } from "./courses.service" ; @ Injectable ( ) export class CourseResolver implements Resolve < Course > { constructor ( private coursesService ) { } resolve ( route , state ) { return this . coursesService . findCourseById ( route . params [ 'id' ] ) ; } }