【发布时间】:2017-05-09 03:24:53
【问题描述】:
当列数据值与我的条件匹配时,我想在行上插入 css 样式
提前致谢
【问题讨论】:
-
这个问题需要充实,包括你尝试过的例子。有关提问的帮助,请参阅 stackoverflow.com/help/how-to-ask。
标签: angular typescript
当列数据值与我的条件匹配时,我想在行上插入 css 样式
提前致谢
【问题讨论】:
标签: angular typescript
使用 ElementRef 指令如下:
import {Component, ElementRef} from "@angular/core";
constructor(private el: ElementRef) {
this.sharedData = sharedResource.SharedComponent;
}
SetRowStyle(colValue)
{
if (colValue == "yourCondition") {
let tableCol= this.el.nativeElement.closest(".tableTd");
tableCol.style.padding = 0;
}
}
注意:我已经在表格列上应用了 css,而且你可以找到它的父级并将 css 应用到行上
【讨论】:
[class]绑定属性会更简洁,避免使用ElementRef。