加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

字形很棒与Angular 2

发布时间:2020-12-17 07:51:17 所属栏目:安全 来源:网络整理
导读:我开了一个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': '
我开了一个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更好.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读