angular - ngb-highlight 选择器的 highlightClass 输入不起作用
问题描述
我正在使用 ngb-highlight 选择器来突出显示表格中包含的一些术语。现在,我想添加背景颜色,并且按照在线文档,我使用了 highlightClass 输入并定义了一个包含这个新属性的自定义类。
使用它的默认类,它可以改变字体粗细。新课程不起作用。
员工列表.component.html
<tr *ngFor="let employee of employees$ | async; index as i">
<th scope="row">{{ i + 1 }}</th>
<td>
<ngb-highlight [result]="employee.firstname" [term]="filter.value" [highlightClass]="'employee-highlight'"></ngb-highlight>
</td>
<td>
<ngb-highlight [result]="employee.lastname" [term]="filter.value" [highlightClass]="'employee-highlight'"></ngb-highlight>
</td>
<td>
<ngb-highlight [result]="employee.email" [term]="filter.value" [highlightClass]="'employee-highlight'"></ngb-highlight>
</td>
<td>
<ngb-highlight [result]="employee.role.name" [term]="filter.value" [highlightClass]="'employee-highlight'"></ngb-highlight>
</td>
</tr>
员工列表.component.scss
.employee-highlight {
background-color: yellow;
}
我希望背景颜色为黄色,但样式不会改变。我能做些什么?
解决方案
看起来 ViewEncapsulation 未在组件中设置为 none
@Component({
....
encapsulation: ViewEncapsulation.None
....
})
推荐阅读
- javascript - 正则表达式过滤器文本匹配反应给空
- php - 我无法使用 PHP 获取 webhook 数据
- html - css - 使 2 显示:table-row 粘在彼此之上
- java - 为什么这个程序打印 13 而不是 15?
- android - 是否可以从 USB 摄像头流式传输视频和从移动麦克风流式传输音频以在 android 中进行 RTMP 流式传输
- azure - Azure 存储队列 - 异地冗余
- date - 在 XSD 中验证日期或日期时间的日期范围?
- scala - 如何映射所有元素都是类型类实例的 HList?
- azure - Azure 搜索架构迁移
- android - 支持 FreeFormWindow 的应用程序在角落启动