我正在尝试在特定时间(角度 2.0.0-rc.4)迭代一个 for 循环。例如。5次或10次..
home.component.html :
{{arr_length}} //printing 10 i.e. I have specified in home.component.ts
<tr *ngFor="let i of arr_length ; let ind = index">
<td>
//code goes here...
</td>
</tr>
但是在*ngFor中它会抛出错误:NgFor only supports binding to Iterables such as Arrays.
我是角度的新手。任何帮助,将不胜感激。
home.component.ts :
import { Component } from '@angular/core';
@Component({
selector: 'home',
templateUrl: '../templates/home.component.html',
directives: [],
providers: []
})
export class HomeComponent
{
arr_length: number;
constructor()
{
this.arr_length = 10;
}
}