Within my angular2 project, I am utilizing FileReader to read a csv file. Once the onloadend
callback is triggered, a variable holds the content of the csv file.
Below is a snippet from my component.ts :
items: Array<any> = []
...
readCSV (event) {
let csvFileParseLog = this.csvFileParseLog;
r.onloadend = function(loadedEvt) {
devicesFile = files[0];
let csvFileParseLog = [];
parseDevicesCsvFile(contents) // A function returning an observable
.subscribe(newItems=> {
csvFileParseLog.push(newItems); // Result stored in csvFileParseLog
},
exception => { ... }
);
};
}
I have attempted to bindcsvFileParseLog
to my view by passing the value into items
, but have not been successful.
Here's how it's represented in my componenet.html :
<div *ngFor="let c of csvFileParseLog">
{{ c.value }}
</div>
Could someone provide guidance on how to display this content within my view component and iterate over it using ngFor?