Install Font Awesome 5 with NPM

后端 未结 5 507
-上瘾入骨i
-上瘾入骨i 2021-02-03 19:21

I am working with Angular(6) application, and I am trying to use FA icons, and drop-down with no luck. I am successfully using FA(4) icons, like:



        
5条回答
  •  野性不改
    2021-02-03 20:04

    For Font Awesome 4.7.0:

    It should work by simply doing:

    npm install font-awesome --save
    

    And adding:

    @import "~font-awesome/css/font-awesome.css";

    ...to your styles.css or styles.scss.


    For Font Awesome 5 use the official Font Awesome 5 angular component

    npm add @fortawesome/fontawesome-svg-core
    npm add @fortawesome/free-solid-svg-icons
    npm add @fortawesome/angular-fontawesome
    

    In your template:

    In your typescript:

    import { faAlignJustify } from '@fortawesome/free-solid-svg-icons';
    
    export class MyComponent {
      faAlignJustify = faAlignJustify;
    }
    

    In the module of your component:

    import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
    
    @NgModule({
      declarations: [
        MyComponent
      ],
      imports: [
        BrowserModule,
        FontAwesomeModule
      ]
    })
    export class MyModule { }
    

提交回复
热议问题