<分区>
我有一种情况需要在同一个元素上使用 *ngIf 和 *ngFor 指令。我在 stackoverlow 上找到了很多答案,但没有找到适合这种情况的答案。
我有一个表,我在其中循环遍历对象数组并在标题中动态写入单元格:
<table border="1" width="100%">
<thead>
<tr>
<td *ngFor="let item of headerItems" *ngIf="item.visible">{{ item?.name }}</td>
</tr>
</thead>
<tbody>
...
</tbody>
</table>
如果对象包含 visible 设置为 true,我想显示/隐藏。我怎样才能做到这一点?