【发布时间】:2017-08-13 06:15:04
【问题描述】:
什么是 angular2 中最优雅的解决方案,用于在 x 行和 y 列中显示 z 数字的 html 表?
X、Y 和 Z 是数字,不一定是集合。该表还应包含数字 1 到 z。
【问题讨论】:
什么是 angular2 中最优雅的解决方案,用于在 x 行和 y 列中显示 z 数字的 html 表?
X、Y 和 Z 是数字,不一定是集合。该表还应包含数字 1 到 z。
【问题讨论】:
我会这样做:Plunker
组件
rows : any[];
cols : any[];
constructor() {
this.rows = Array(50).fill('');
this.cols = Array(10).fill('');
}
模板:
<table>
<tr *ngFor="let row of rows; let rowId = index">
<td *ngFor="let col of cols; let colId = index">{{rowId + colId*10+1}}</td>
</tr>
</table>
【讨论】: