type="button"
id="exportJson"
(click)="exportJson()">Export</button>
- <a [href]="downloadJsonHref"
- id="exportLink"
+ <a id="exportLink"
+ [href]="downloadJsonHref"
[hidden]="downloadJsonHref === ''"
download="speisekarte.json">Download</a>
<button class="button"
public exportJson(): void
{
- this.downloadJsonHref = this.jsonFileService.exportJson(
- this.foodcard);
+ let observ = this.jsonFileService.exportJson(this.foodcard);
+ observ.subscribe((next) => {
+ this.downloadJsonHref = next;
+ });
}
public fileEvent(event: any): void
let importobserv = this.jsonFileService.importJson(event);
importobserv.subscribe((next) => {
this.foodcard = next;
- console.log(next);
});
}
{
constructor(private sanitizer: DomSanitizer) {}
- public exportJson(foodcard: IFoodCard): SafeUrl
+ public exportJson(foodcard: IFoodCard): Observable<string>
{
- let json = JSON.stringify(foodcard);
- return this.sanitizer.bypassSecurityTrustUrl(
- "data:text/json;charset=UTF-8," + json);
+ let observ = new Observable<string>((observ) => {
+ let json = JSON.stringify(foodcard);
+ let result = <string> this.sanitizer.bypassSecurityTrustUrl("data:text/json;charset=UTF-8," + json);
+ observ.next(result);
+ });
+
+ return observ
}
public importJson(event: any): Observable<IFoodCard>