font-awesome npm angular code example

Example 1: font awesome angular

//install in your project directory
npm install --save @fortawesome/fontawesome-free

// in angular.json add in the 'build' section the following lines in 'styles' and 'scripts'
"styles": [
           "node_modules/@fortawesome/fontawesome-free/css/all.css"
        ]

"scripts": [
          "node_modules/@fortawesome/fontawesome-free/js/all.js"
        ]

//from now on, you can use fontawesome icons through the <i>
    <i class='fab fa-facebook'></i>

Example 2: font awesome install in angular

npm install --save font-awesome angular-font-awesome
//once installed you will to import font awesome to your app.module.ts
import { AngularFontAwesomeModule} from 'angular-font-awesome';
//on your app.module.ts add AngularFontAwesomeModule under imports
imorts[
.../
AngularFontAwesomeModule,
],

Example 3: add font awesome to angular

<!--In the index.html-->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">

Example 4: npm font awesome 5 angular 7

# See Compatibility table below to choose a correct version
$ ng add @fortawesome/angular-fontawesome@<version>

Example 5: how to get fas icons in angualr

import { library } from '@fortawesome/fontawesome-svg-core';
import { fas } from '@fortawesome/free-solid-svg-icons';
import { far } from '@fortawesome/free-regular-svg-icons';
library.add(fas, far);

Tags:

Misc Example