I have the following component that load a file and bind his content as string
export class NgCsvComponent {
@Input() csv: any;
@Output() csvChange: any = new EventEmitter();
public localCsv : any = '';
constructor() { }
changeListener($event): void {
this.readFile($event.target);
}
readFile (inputValue : any) : void {
let reader = new FileReader (),
file : File = inputValue.files[0];
reader.readAsText(file);
reader.onload = this.onLoadCallback;
}
onLoadCallback (event) {
this.csvChange.emit(event.target["result"]);
}
}
the problem is that this.csvChange is undefined inside onLoadCallback so how I could pass the result to some variable in my component?
I was search other similar question but never get the result outside of onloadCallback function