From d972798bd82a100c6ce15e6f495e4718d32b846c Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Mon, 13 Jun 2022 18:31:55 +0200 Subject: [PATCH] change: load css with observable in constructor --- src/app/html-export.service.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 -- 2.39.5