我正在尝试创建一个功能模块,该功能模块可以处理“真棒字体”图标的导入并将其导入到应用程序模块中,但是当我尝试添加图标时,它给了我这个错误
Uncaught Error: Template parse errors:
Can't bind to 'icon' since it isn't a known property of 'fa-icon'.
应用模块
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { IconsModule } from './icons.module';
@NgModule({
declarations: [
],
imports: [
BrowserModule,
AppRoutingModule,
IconsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
图标功能模块
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'
import { library } from '@fortawesome/fontawesome-svg-core';
import { faArrowAltRight } from '@fortawesome/pro-light-svg-icons';
library.add(faArrowAltRight);
@NgModule({
imports: [CommonModule, FontAwesomeModule],
declarations: [
],
providers: [],
exports: []
})
export class IconsModule {}
答案 0 :(得分:0)
好的。我知道了。我添加了这个:
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'
导入应用模块。
答案 1 :(得分:0)
您需要导出需要在应用程序或其他模块中使用的模块,以下为示例
@NgModule({
imports: [CommonModule, FontAwesomeModule],
declarations: [
],
providers: [],
exports: [FontAwesomeModule]
})