如何将变量赋值给primeng TurboTable ColGroup colspan属性。
<ng-template pTemplate="header">
<tr>
<th rowspan="3">Brand</th>
<th colspan="4">Sale Rate</th>
</tr>
<tr>
<th colspan="colSpanCount">Sales</th>
<th colspan="2">Profits</th>
</tr>
<tr>
<th>Last Year</th>
<th>This Year</th>
<th>Last Year</th>
<th>This Year</th>
</tr>
</ng-template>
在上面的例子中,我想将colSpanCount变量绑定到p-table的colspan属性。
答案 0 :(得分:0)
我想,我自己找到了答案。我们可以设置[attr.colspan] =&#34; colSpanCount&#34;属性动态设置colspan。
<ng-template pTemplate="header">
<tr>
<th rowspan="3">Brand</th>
<th colspan="4">Sale Rate</th>
</tr>
<tr>
<th [attr.colspan]="colSpanCount">Sales</th>
<th colspan="2">Profits</th>
</tr>
<tr>
<th>Last Year</th>
<th>This Year</th>
<th>Last Year</th>
<th>This Year</th>
</tr>
</ng-template>
答案 1 :(得分:0)
正如您所发现的那样,您可以将colspan
更改为[attr.colspan]
。
另一种解决方案是将colspan
更改为[colSpan]
。