我只想隐藏表中最后一列'Id'的行取决于一些条件if(colValue ==“Id”)。angular2 - 隐藏隐藏行列使用隐藏
<thead>
<tr>
<th *ngFor="let colValue of headerRow" [hidden]="colValue == Id">{{colValue}}</th>
</tr>
下面是该行的列。
否|日期|名称|类型|状态|平衡|评论| Id |
我不想隐藏,但想隐藏。我怎么能做到这一点?由于
我只想隐藏表中最后一列'Id'的行取决于一些条件if(colValue ==“Id”)。angular2 - 隐藏隐藏行列使用隐藏
<thead>
<tr>
<th *ngFor="let colValue of headerRow" [hidden]="colValue == Id">{{colValue}}</th>
</tr>
下面是该行的列。
否|日期|名称|类型|状态|平衡|评论| Id |
我不想隐藏,但想隐藏。我怎么能做到这一点?由于
使用https://angular.io/docs/ts/latest/api/common/index/NgIf-directive.html
<tr>
<th *ngFor="let colValue of headerRow" *ngIf="colValue != Id">{{colValue}}</th>
</tr>
您可以创建CSS样式,然后绑定类的CSS元素
.hide {
display: none;
}
然后在模板:
<th [class.hide]="colValue == Id"></th>
忌用hidden
属性,它可能当绑定到主机时会导致一个错误。和hidden
将添加display: none !important
。
我看到您正在尝试创建表格组件。我会建议不要这样做。您可能最终会在JavaScript中代替html页面中的很多gui代码。我可以问为什么它需要隐藏?为什么* ngIf不够?
当我有更多的行,如果我点击任何行,我得到存储在每个表行的最后一列的'id'值。从'id'我将显示更多结果(如向下钻取)。 –
你不需要在html元素中做到这一点:这里是一个例子。 '
* ngIf将从DOM中删除最后一列。但我想隐藏(HiddenField) –