font awesome with Angular 2

前端 未结 4 1057
一整个雨季
一整个雨季 2020-12-19 09:42

I started an NG2 app and wanna add font awesome. I npm installed it with : npm install --save font-awesome angular2-font-awesome. I added to project in systemjs.config.js:

相关标签:
4条回答
  • 2020-12-19 10:14

    if you wanna using FontAwesome css style in your app, just put css link to your index.html, you don't need angular2-font-awesome

    index.html

    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    

    if you using angular2-font-awesome

    <i fa [name]="industry"></i>
    <fa [name]="industry"></fa>
    

    i think use cdn is better.

    0 讨论(0)
  • 2020-12-19 10:14

    I think you need to add it to your .angular-cli.json section like this:

    you may have it under a different name in your node_modules. try to go down the list in node_modules and see under what name it has been installed. The other thing I noticed is npm install --save font-awesome angular-font-awesome

    `"styles": [
        "styles.css",
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "../node_modules/font-awesome/css/font-awesome.css",
        "../node_modules/npm-font-open-sans/open-sans.styl"
    
    
      ],
    
    0 讨论(0)
  • 2020-12-19 10:21

    Not much of effort is needed just include the script tag.

    <div>
          <h2>Hello {{name}}</h2>
          <i class="fa fa-home"></i>
    </div>
    

    and my index.html contains script reference to the above script URL.

    Get your script code by Registering Here. You will receive a mail from font-awesome as below

    LIVE DEMO

    0 讨论(0)
  • 2020-12-19 10:26

    Try to use this method:

    Firstly install font awesome using command : npm install --save font-awesome angular-font-awesome

    secondly, import it in your style.scss file with

    $fa-font-path: "../node_modules/font-awesome/fonts";
    @import "../node_modules/font-awesome/scss/font-awesome.scss";
    

    or to your style.css file with

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

    command. The fonts are ready to use.

    Now place your font in any html file. <i class="fa facebook"></i>

    0 讨论(0)
提交回复
热议问题