Search Posts

Category: fabricjs

How do I read a JSON file in Angular?

I am trying to load a JSON file from local disk and use the data from it to fill a FabricJS canvas. I have problems on getting the data from the file. This is what i have till now. app.html <input type=”file” accept=”.json” id=”fileInput” (change)=”loadFile($event)”/> app.ts loadFile(event) { const eventObj: MSInputMethodContext = <MSInputMethodContext> event; const target: HTMLInputElement = <HTMLInputElement> eventObj.target; const files: FileList = target.files; this.file = files[0]; const reader = new FileReader(); reader.readAsText(this.file, ‘utf8’); […]