import { Component , OnInit } from "@angular/core" ; import { HttpClient } from "@angular/common/http" ; import { DomSanitizer } from "@angular/platform-browser" ; import * as MarkDownIt from "markdown-it" ; import { LoggerService } from "../shared/services/logging/logger.service" ; @ Component ( { selector : "app-faq" , templateUrl : "./faq.component.html" , styleUrls : [ "./faq.component.scss" ] } ) export class FaqComponent implements OnInit { private static readonly FAQ_URL : string = "https://raw.githubusercontent.com/wiki/thomaschampagne/elevate/Frequently-Asked-Questions.md" ; public html : string ; public markDownParser : MarkDownIt ; public isFaqLoaded : boolean = null ; constructor ( public httpClient , public domSanitizer , public logger ) { } public ngOnInit ( ) { this . markDownParser = new MarkDownIt ( ) ; this . httpClient . get ( FaqComponent . FAQ_URL , { responseType : "text" } ) . toPromise ( ) . then ( ( markdownData ) => { this . html = < string > this . domSanitizer . bypassSecurityTrustHtml ( this . markDownParser . render ( markdownData ) ) ; this . isFaqLoaded = true ; } , err => { this . logger . error ( err ) ; } ) ; } }