<th *ngFor="let item of cols" nzWidth="{{ item.width }}" nzAlign="{{ item.alignCaption }}"
*ngIf="{{ item.visible }}">
{{ item.caption }}
</th>
ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't have multiple template bindings on one element. Use only one attribute prefixed with (" <th ngFor="let item of cols" nzWidth="{{ item.width }}" nzAlign="{{ item.alignCaption }}" [ERROR ->]*ngIf="{{ item.visible }}">{{ item.caption }} </th>
- 看出来是使用了多个
*ngXxx
的问题,但是要如何解决我的需求?
- 通过
*ngFor
循环创建表格列头,其中根据属性item.visible
动态设定该列头是否显示
- 我使用了
style.display:none
,但是布局会错位(这里的none
去掉了DOM元素的展位)
- 还测试了
style.visibility:hidden
,这样会保留占位,结果是有空白出现了。。
- 要如何达到我要的效果?
- 有必要的话QQ:409223171