Adding Font Awesome 5 icon from Angular 5 component

流过昼夜 提交于 2019-12-11 08:42:25

问题


I am using Font Awesome 5 (angular2-fontawesome - package) with Angular 5.

What I am trying to do is to import fa icon from component.

Html:

<mat-list>
     <mat-list-item><a [routerLink]="['/']" fragment="intro-text" [innerHTML]="introText"> {{introText}} </a></mat-list-item>
     ...
</mat-list>

Component:

introText = "Welcome";

@HostListener("window:resize", ["$event"])
onResize(event) {      
  this.introText = window.innerWidth < 1080 ? '<i fa class="fas fa-home"></i> <h1>1</h1>' : "Welcome";
}   

When I am above from 1080 pixels it shows me "Welcome" and when is below it shows me the number 1 bold and big.

The problem is that icon it didn't show up. I checked to put...

<i fa class="fas fa-home">

in Html and it works but from component it didn't. Why and what can I do to fix this?


回答1:


Bootstrap 4 has removed Font Awesome import , you need to explicitly import Font Awesome .



来源:https://stackoverflow.com/questions/50189242/adding-font-awesome-5-icon-from-angular-5-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!