I use angular2 in one of my project. I would like to display one of my global variable in the view. However this value its initialized into a FileReader, and I cannot pass the callback result to my global variable...
here my code :
 csvFileParseLog: Array<any> = [];
 ...
 let test = this.test;
 let csvFileParseLog = this.csvFileParseLog;
 r.onloadend = function(loadedEvt) {
    devicesFile = files[0];
    let csvFileParseLog = [];
    parseDevicesCsvFile(contents) // One of my function which is an observable
      .subscribe(newDevice => {
          test(newDevice);
          csvFileParseLog.push(newItems); // Wrong format
      },
      exception => { ... }
      );
  };
  r.readAsText(files[0]);
And in the same file :
private test(result) {
    this.csvFileParseLog.push(result);
 }
I have this error :
Cannot read property 'csvFileParseLog' of undefined
How can I pass my callback result to my global variable
