如何在角度属性中将属性绑定与td属性colspan一起使用? [英] How to use property binding with td attribute colspan in angular?
问题描述
我正在按角度处理表格元素. Al通过我的代码可以正常工作.但是当我需要在td
属性colspan
上实现属性绑定时,它向我显示了浏览器控制台中的以下错误:
I was working on table element in angular. Al through my code works fine. But when I need to implement property binding on td
attribute colspan
its showing me below error in browser console:
Uncaught Error: Template parse errors:
Can't bind to 'colspan' since it isn't a known property of 'td'. ("Total Rows:
</td>
<td [ERROR ->]colspan="{{count}}">
{{rows}}
</td>
我尝试过的是:
<table class="table table-hover" width="100%">
<tr>
<th *ngFor="let col of columns">
{{col}}
</th>
</tr>
<tr *ngFor="let data of getFilteredData">
<td *ngFor="let col of columns">
{{data[col]}}
</td>
</tr>
<tr>
<td colspan="{{count}}">
Total Rows: {{rows}}
</td>
</tr>
</table>
我想要的东西:
在我的.ts文件中,我为columns数组的长度赋予count
值,以便使用属性绑定平均分配我的页脚单元的列长.
In my .ts file I give count
value to the length of columns array so what ever the columns length are my footer cell have equally distributed using property binding.
我也尝试:
- [colspan] =计数"
- colspan ='count'"
但是这些都不起作用,并且显示出相同的错误.
but none of this worked and showing the same error.
推荐答案
尝试一下,
如果要绑定到属性,请使用[attr.colspan]="count"
语法
If you want to bind to an attribute use [attr.colspan]="count"
syntax
这篇关于如何在角度属性中将属性绑定与td属性colspan一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!