]> gitweb.hhaalo.de Git - speisekarten-editor.git/commitdiff
change: load css with observable in constructor
authorBastian Dehn <hhaalo@arcor.de>
Mon, 13 Jun 2022 16:31:55 +0000 (18:31 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Mon, 13 Jun 2022 16:31:55 +0000 (18:31 +0200)
src/app/html-export.service.ts

index 340464bcc064e90b346e37267a08c553032f2c5b..68a13de71c540190e2d5f15be902dbc6e7ae6f5d 100644 (file)
@@ -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<SafeUrl>
        {
-               this.loadCssFile();
                let observ = new Observable<SafeUrl>((observ) => {
                        let html: string = '<html lang="de">';
                        html += '<head>';
@@ -48,9 +49,9 @@ export class HtmlExportService
                return observ;
        }
 
-       private loadCssFile(): void
+       private loadCssFile(cssFilePath: string): Observable<Object>
        {
-               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