字形很棒与Angular 2

前端之家收集整理的这篇文章主要介绍了字形很棒与Angular 2前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我开了一个NG2应用程序,想要添加字体真棒.
我用它安装了它:npm install –save font-awesome angular2-font-awesome.
我在systemjs.config.js中添加了项目:
map: {
  // our app is within the app folder
  app: 'app',// angular bundles
  '@angular/core': 'npm:@angular/core/bundles/core.umd.js','@angular/common': 'npm:@angular/common/bundles/common.umd.js','@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js','@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js','@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js','@angular/http': 'npm:@angular/http/bundles/http.umd.js','@angular/router': 'npm:@angular/router/bundles/router.umd.js','@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',// other libraries
  'rxjs':                      'npm:rxjs','angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js','angular2-fontawesome': 'node_modules/angular2-fontawesome'
},// packages tells the System loader how to load when no filename and/or no extension
packages: {
  app: {
    defaultExtension: 'js'
  },rxjs: {
    defaultExtension: 'js'
  },'angular2-fontawesome': { defaultExtension: 'js' }
}

我在app.module.ts中添加了:

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent }  from './app.component';
import { CorporateComponent }  from './corporate/corporate.component';
import { Angular2FontawesomeModule } from 'angular2-fontawesome/angular2-fontawesome'

@NgModule({
  imports:      [ BrowserModule,Angular2FontawesomeModule],declarations: [ AppComponent,CorporateComponent ],bootstrap:    [ AppComponent ]
})
export class AppModule { }

现在我尝试在我的组件中使用它:
我在html模板中添加

<i class="fa fa-industry" aria-hidden="true"></i>

但不知怎的,我没有看到它……
我按照npm:https://www.npmjs.com/package/angular2-fontawesome的手册进行操作

还有什么我可能忘记的吗?

谢谢你的回答!

如果你想在你的应用程序中使用FontAwesome css样式,只需将css链接放到你的index.html,你就不需要angular2-font-awesome

的index.html

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

如果你使用angular2-font-awesome

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

我认为使用cdn更好.

原文链接:https://www.f2er.com/angularjs/143331.html

猜你在找的Angularjs相关文章