-import { Injectable } from '@angular/core';
+import { Injectable, OnDestroy } from '@angular/core';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { HttpClient } from '@angular/common/http';
-import { Observable } from 'rxjs';
+import { Observable, Subscription } from 'rxjs';
import { IFoodCard } from './ifood-card';
import { ITitle } from './ititle';
import { ISubtitle } from './isubtitle';
providedIn: 'root'
})
-export class HtmlExportService
+export class HtmlExportService implements OnDestroy
{
+ private subscriptions: Subscription[] = [];
private cssExportContent: string = "";
private cssPrintExportContent: string = "";
private httpclient: HttpClient)
{
let loadcss: Observable<SafeUrl> = this.loadCssFile("assets/htmlexport.css");
- loadcss.subscribe((content: any) => {
- this.cssExportContent = content as string; });
+ this.subscriptions.push(loadcss.subscribe((content: any) => {
+ this.cssExportContent = content as string; }));
loadcss = this.loadCssFile("assets/htmlprintexport.css");
- loadcss.subscribe((content: any) => {
- this.cssPrintExportContent = content as string; });
+ this.subscriptions.push(loadcss.subscribe((content: any) => {
+ this.cssPrintExportContent = content as string; }));
}
public exportHtml(foodcard: IFoodCard): Observable<SafeUrl>
return divElement;
}
+
+ public ngOnDestroy(): void
+ {
+ this.subscriptions.forEach(s => s.unsubscribe());
+ }
}