From: Bastian Dehn Date: Mon, 6 Jun 2022 16:39:29 +0000 (+0200) Subject: add: event to load json file X-Git-Tag: v1.0^2~35 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=9d8d9b8091e6cb50fd71e90b75b18b272f88c15c;p=speisekarten-editor.git add: event to load json file --- diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 72e3e6a..ef7399f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -72,9 +72,13 @@ export class AppComponent this.downloadJsonHref = uri; } - public fileEvent(fileInput: Event): void + public fileEvent(event: any): void { - console.log(fileInput); + const reader = new FileReader(); + reader.onload = (e: any) => { + this.foodcard = JSON.parse(e.target.result); + } + reader.readAsText(event.target.files[0]); } public addTitle(): void