1
在我的angular2項目中,我使用FileReader讀取了一個csv文件。在onloadend
回調之後,我有一個包含我的csv文件內容的變量。Angular2:使用回調變量綁定視圖
這裏我component.ts:
items: Array<any> = []
...
readCSV (event) {
let csvFileParseLog = this.csvFileParseLog;
r.onloadend = function(loadedEvt) {
devicesFile = files[0];
let csvFileParseLog = [];
parseDevicesCsvFile(contents) // One of my function which is an observable
.subscribe(newItems=> {
csvFileParseLog.push(newItems); // My result
},
exception => { ... }
);
};
}
我試圖通過我的價值結合csvFileParseLog
我的看法到items
......成功的內部消除。
這裏我componenet.html:
<div *ngFor="let c of csvFileParseLog">
{{ c.value }}
</div>
我怎樣才能顯示此內容在我的視圖組件和環路上它與ngFor?
如果你能分享你迄今爲止的代碼,這將是非常有幫助的。 :) – toskv
當然是的:)我做到了! – onedkr