【发布时间】:2019-10-13 21:23:40
【问题描述】:
我正在尝试根据组件中的布尔值显示和隐藏标题和行。我能够隐藏特定的 td 但无法隐藏特定的列。在下面的示例中,我试图隐藏包含 th 和 td 元素的 Last Edited 行。如果我将布尔变量设置为 false,则不会显示该列的 td,但我如何隐藏标题。如果我提出以下条件,它似乎不起作用
<th *ngIf="c == ColumnNames[1] && showCol""
HTML
<div *ngIf="LegalFundClasses && LegalFundClasses.LegalFundClassDetailsViewModel && ColumnNames">
<table class="fundClassesTable table-striped">
<tr *ngFor="let c of ColumnNames">
<th [ngClass]="c != ColumnNames[2] ? 'tableItem bold' : 'cellbgcolor'" >{{ c }}</th>
<ng-container *ngFor="let f of LegalFundClasses.LegalFundClassDetailsViewModel; let i=index">
<td class="tableItem" *ngIf="c == ColumnNames[0]">{{f.Description}}</td>
<td class="tableItem" *ngIf="c == ColumnNames[1] && showCol">{{f.AuditSummary}}</td>
<td class="tableItem" *ngIf="c == ColumnNames[2]">{{f.Id}}</td
</ng-container>
</tr>
</table>
</div>
组件
public showCol: boolean = false;
public ColumnNames: string[] = ['Legal Class Name',
'Last Edited',
'Legal Class ID'
];
这是小提琴
【问题讨论】:
标签: angular