【发布时间】:2017-06-25 16:46:20
【问题描述】:
我启动了一个 NG2 应用程序并想添加很棒的字体。 我使用 npm 安装它: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
还有什么我可能忘记的吗?
感谢您的任何回答!
【问题讨论】:
-
你下载了他们的
font-awesome字体(otf|eot|svg|ttf|woff|woff2)吗? -
请查看文档,您必须像
一样使用它 -
是的,而不是使用 ng2 插件,使用 font awesome 原始链接是一个更好的选择。