离子3如何在打字稿中使用for循环?

时间:2018-08-07 11:45:07

标签: typescript for-loop ionic-framework

我们可以像

那样在ngFor中使用HTML
*ngFor="let file of files"

但是我想在打字稿中应用 For循环。我如何使用 For循环

3 个答案:

答案 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){

}