使用npm像提到的in github
将 angular-fontawesome 安装到angular应用中在开发模式下工作正常。但是在生产版本中出现了错误。
当然,最初的错误是
NullInjectorError: StaticInjectorError(Do)[qm -> t]: StaticInjectorError(Platform: core)[qm -> t]: NullInjectorError: No provider for t!
必须将 angular.json 中的设置更改为
"optimization": false,...
"buildOptimizer": true,
找出实际错误
NullInjectorError: StaticInjectorError(AppModule)[FaIconComponent -> FaConfig]: StaticInjectorError(Platform: core)[FaIconComponent -> FaConfig]: NullInjectorError: No provider for FaConfig!
我该如何解决。
该模块具有
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
已添加到导入
@NgModule({
declarations: [...],imports: [
...
FontAwesomeModule
],
组件具有
import { faEllipsisV,... } from '@fortawesome/free-solid-svg-icons';
就像在指南中提到的那样。
这里是依赖项
"dependencies": {
"@angular/animations": "~8.2.11","@angular/cdk": "~8.2.3","@angular/common": "~8.2.11","@angular/compiler": "~8.2.11","@angular/core": "~8.2.11","@angular/forms": "~8.2.11","@angular/material": "^8.2.3","@angular/platform-browser": "~8.2.11","@angular/platform-browser-dynamic": "~8.2.11","@angular/router": "~8.2.11","@fortawesome/angular-fontawesome": "^0.6.0-alpha.0","@fortawesome/fontawesome-svg-core": "^1.2.25","@fortawesome/free-solid-svg-icons": "^5.11.2","bootstrap": "^4.3.1","classlist.js": "^1.1.20150312","hammerjs": "^2.0.8","ngx-bootstrap": "^5.2.0","ngx-cookie-service": "^2.2.0","ngx-webstorage-service": "^4.1.0","rxjs": "~6.4.0","tslib": "^1.10.0","web-animations-js": "^2.3.2","zone.js": "~0.9.1"
}
Angular版本8.3.12.