【发布时间】:2018-02-03 09:46:02
【问题描述】:
我有一张这样的表格:
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
.blue {
background-color: blue;
}
.green {
background-color: green;
}
.red {
background-color: red;
}
<table>
<thead>
<tr>
<th class="blue">item 1</th>
<th class="green" colspan="2">item 2</th>
<th class="red" colspan="3">item 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>data</td>
<td>data</td>
<td>data</td>
<td>data</td>
<td>data</td>
<td>data</td>
</tr>
</tbody>
</table>
我想动态地将 colspan 和颜色添加到角度 4 中的不同 th 标记: 在我的角度应用程序中,我有:
.html 文件
<tr *ngFor="let item of items">
<th>{{ item }}</th>
</tr>
.ts 文件
items: string[] = ['item 1', 'item 2', 'item 3']
如何添加这些不同的 colspans 和颜色(看看我想要实现的 sn-p)?非常感谢。
【问题讨论】:
标签: javascript angular