如何在角度中使用属性绑定与td属性colspan?

Ahm*_*san 14 angular

我正在研究角度的表格元素.Al通过我的代码工作得很好.但是,当我需要实现性能上的结合td属性,colspan其显示在下方浏览器控制台错误我:

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>
Run Code Online (Sandbox Code Playgroud)

我试过的是:

<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>
Run Code Online (Sandbox Code Playgroud)

我想要的是:

在此输入图像描述

在我的.ts文件中,我给count列数组的长度值,所以列长度是我的页脚单元格使用属性绑定同样分布.

我也尝试:

  • [列跨度] = "计数"
  • 列跨度="'计数’"

但这些都没有奏效并显示出同样的错误.

Hit*_*ara 43

试试这个,

如果要绑定到属性,请使用[attr.colspan] ="count"语法