[Angular Material] 在table抓取最後一行做樣式
angular material table中
因為*matRowDef是語法糖
裡面包含了*ngFor
所以可以運用
https://angular.io/api/common/NgForOf#local-variables
中的導出值
所以加上
let last = last
以及加上
[ngClass]="{ 'last-child': last }"
讓指定的最後一個元素有class
有了class後就能用css去指定並設定樣式
HTML
<tr
mat-row
*matRowDef="
let row;
columns: innerDisplayedColumns;
let last = last
"
[ngClass]="{ 'last-child': last }"
></tr>
CSS
.last-child {
font-weight: bold;
}
留言
張貼留言