【发布时间】:2018-08-08 14:47:18
【问题描述】:
我们可以在HTML中使用ngFor,就像
*ngFor="let file of files"
但我想在打字稿中应用 For 循环。如何使用 For 循环。
【问题讨论】:
标签: typescript for-loop ionic-framework
我们可以在HTML中使用ngFor,就像
*ngFor="let file of files"
但我想在打字稿中应用 For 循环。如何使用 For 循环。
【问题讨论】:
标签: typescript for-loop ionic-framework
很简单:
for(let file of this.filename) {
console.log(file);
}
或喜欢:
for(let i = 0; i < this.filename.length; i++) {
console.log(this.filename[i]);
}
【讨论】:
参考此代码,
for (let file of this.files){
}
【讨论】:
这里是你如何使用forEach:
files.forEach((res) => {
//your each object will be in res
//example: let value = res
});
【讨论】: