Estoy tan confundido acerca de esto, pero ¿hay alguna manera de almacenar el contenido de FileReader en una variable o una matriz tal como está, porque necesito ese contenido en otro componente?
Este es mi fragmento de código:
fileChangeListener($event: any): void { this.fileSize = Math.round($event.target.files[0].size /1024) + 'KB'; this.fileName = $event.target.files[0].name; this.fileType = $event.target.files[0].type; this.filelastModifiedDate = new Date($event.target.files[0].lastModified).toLocaleDateString(); console.log(this.fileName, this.fileType); console.log('submitted here'); const file = $event.target.files[0]; const fileReader = new FileReader(); fileReader.onload = (e) => { const data = fileReader.result; this.storeResults(data); this._fileReader = data; // console.log('FileREAAAAAAAAAAADER \n', data); console.log(this._fileReader); this.parseData(data); }; return fileReader.readAsText(file); }componente.html:
<mat-form-field (change)="fileChangeListener($event)"> <ngx-mat-file-input formControlName="multiplefile" placeholder="Multiple inputs" multiple></ngx-mat-file-input> <mat-icon matSuffix>folder</mat-icon> </mat-form-field>