import { HttpClient } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; import { ActivatedRouteSnapshot , Resolve , Router } from '@angular/router' ; import { of , Observable } from 'rxjs' ; import { catchError , take } from 'rxjs/operators' ; /**
 * Help resolver
 */ @ Injectable ( { providedIn : 'root' , } ) export class HelpResolver implements Resolve < String > { param router param http constructor ( private router , private http ) { } param route resolve ( route ) { const path = route . params . path ; return this . http . get ( `/assets/help/${ path }.md` , { responseType : 'text' } ) . pipe ( take ( 1 ) , catchError ( ( ) => { this . router . navigate ( [ '/help' ] ) ; return of ( '' ) ; } ) ) ; } }