angular-material - Angular Material Table:如何突出显示正在排序的列?
问题描述
使用 Angular Material 表。如何对正在排序的列应用不同的背景颜色?
解决方案
如果您只想<th>
在排序时更改颜色,请分配一个模板参考,并进入参考以检查排序是否处于活动状态并且排序值是否存在。
<th mat-header-cell #header *matHeaderCellDef mat-sort-header
[style.background-color]="
(header['_sort'].active == 'id' && header['_sort'].direction) ?'red':''"> ID </th>
StackBlitz
https://stackblitz.com/edit/angular-5fzkja?embed=1&file=app/table-overview-example.html
推荐阅读
- asp.net-mvc - 我的数据库中的 EntityState.Modify 而不是 Delete
- c# - 使用 ASP.Net 发送 SMTP 邮件
- d3.js - Setting the color of the nodes in d3
- html - Html:文本不在表格下,但应该在
- ios - Firebase 云消息传递中 iOS 的 ttl“生存时间”是否有替代方案?
- c - C Replacing Variable Number
- javascript - Fire a CustomEvent from element in dom-repeat
- sd-card - 为什么 File.mkdirs() 创建两个目录而不是一个?
- c# - 将文档与 Xceed Docx 合并后,标题会丢失样式
- java - 需要详细了解“@”符号如何在 google cloud apache 梁代码中使用