]> gitweb.hhaalo.de Git - speisekarten-editor.git/commitdiff
add: event to load json file
authorBastian Dehn <hhaalo@arcor.de>
Mon, 6 Jun 2022 16:39:29 +0000 (18:39 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Mon, 6 Jun 2022 16:39:29 +0000 (18:39 +0200)
src/app/app.component.ts

index 72e3e6a9e00ae22cf56dc507db8d5b453297779d..ef7399f5005ab8f332941d6aad9dd05a088a69d5 100644 (file)
@@ -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