From: Bastian Dehn Date: Mon, 13 Jun 2022 16:31:55 +0000 (+0200) Subject: change: load css with observable in constructor X-Git-Tag: v1.0.1^2~2 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=d972798bd82a100c6ce15e6f495e4718d32b846c;p=speisekarten-editor.git change: load css with observable in constructor --- diff --git a/src/app/html-export.service.ts b/src/app/html-export.service.ts index 340464b..68a13de 100644 --- a/src/app/html-export.service.ts +++ b/src/app/html-export.service.ts @@ -18,12 +18,13 @@ export class HtmlExportService constructor(private sanitizer: DomSanitizer, private httpclient: HttpClient) { - this.loadCssFile(); + let loadcss = this.loadCssFile("assets/htmlexport.css"); + loadcss.subscribe((content: any) => { + this.cssExportContent = content as string; }); } public exportHtml(foodcard: IFoodCard): Observable { - this.loadCssFile(); let observ = new Observable((observ) => { let html: string = ''; html += ''; @@ -48,9 +49,9 @@ export class HtmlExportService return observ; } - private loadCssFile(): void + private loadCssFile(cssFilePath: string): Observable { - let loadcss = this.httpclient.get("assets/htmlexport.css", + return this.httpclient.get(cssFilePath, { headers: { @@ -59,8 +60,6 @@ export class HtmlExportService }, responseType: 'text' }); - loadcss.subscribe((content: any) => { - this.cssExportContent = content as string; }); } private createHtmlTitles(titles: ITitle[]): string