我们可以像
那样在ngFor
中使用HTML
*ngFor="let file of files"
但是我想在打字稿中应用 For循环。我如何使用 For循环。
答案 0 :(得分:1)
很简单:
for(let file of this.filename) {
console.log(file);
}
或类似的
for(let i = 0; i < this.filename.length; i++) {
console.log(this.filename[i]);
}
答案 1 :(得分:0)
以下是您如何使用forEach的方法:
files.forEach((res) => {
//your each object will be in res
//example: let value = res
});
答案 2 :(得分:-1)
请参阅此代码,
for (let file of this.files){
}