简体   繁体   English

Angular 7:材料按钮图标在数据表的 header 中不起作用

[英]Angular 7: Material Button Icon doesn't work in the header of a datatable

I'm trying to add a refresh button to a Material Data Table on Angular 7, but the name of the icon, refresh is shown in italic instead of the icon.我正在尝试在 Angular 7 上的材料数据表中添加一个刷新按钮,但图标的名称refresh以斜体而不是图标显示。

The relevant code is shown below:相关代码如下所示:

<table mat-table [dataSource]="myDataSource">
  <!-- other rows... -->

  <ng-container matColumnDef="buttons">
    <th mat-header-cell *matHeaderCellDef>
      <button (click)="reload()" mat-icon-button>
        <i class="material-icons" alt="reload">refresh</i>
      </button>
    </th>
    <td mat-cell *matCellDef="let row">
      <!-- buttons for each row here -->
    </td>
  </ng-container>
</table>

Is it not possible to add a material icon to the header of a datatable?不能在数据表的header中添加材质图标吗?

It did work with a normal table.它确实适用于普通桌子。

Found the problem.发现了问题。

The font-family being applied to the header was shadowing the Material Icons font.应用于 header 的font-family遮盖了Material Icons字体。

Adding the correct font to the style of the component, as well as removing the italic style, solved the issue.为组件的样式添加正确的字体,以及删除斜体样式,解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM