[英]ERROR TypeError: Cannot read property 'html' of undefined (angular-fontawesome)
I would like to use fontawesome in my Angular project. 我想在我的Angular项目中使用fontawesome。 I would like to try out FortAwesome/angular-fontawesome , but I get an error in the browser console, if I try to use an icon:
我想尝试FortAwesome / angular-fontawesome ,但是如果尝试使用图标,则会在浏览器控制台中出现错误:
ERROR TypeError: Cannot read property 'html' of undefined
at FaIconComponent.ngOnChanges (webpack-internal:///../../../../@fortawesome/angular-fontawesome/@fortawesome/angular-fontawesome.es5.js:112)
at checkAndUpdateDirectiveInline (webpack-internal:///../../../core/esm5/core.js:12576)
at checkAndUpdateNodeInline (webpack-internal:///../../../core/esm5/core.js:14104)
at checkAndUpdateNode (webpack-internal:///../../../core/esm5/core.js:14047)
at debugCheckAndUpdateNode (webpack-internal:///../../../core/esm5/core.js:14940)
at debugCheckDirectivesFn (webpack-internal:///../../../core/esm5/core.js:14881)
at Object.eval [as updateDirectives] (ng:///AppModule/AppComponent.ngfactory.js:154)
at Object.debugUpdateDirectives [as updateDirectives] (webpack-internal:///../../../core/esm5/core.js:14866)
at checkAndUpdateView (webpack-internal:///../../../core/esm5/core.js:14013)
at callViewAction (webpack-internal:///../../../core/esm5/core.js:14364)
I installed @fortawesome/angular-fontawesome
and the two dependencies ( @fortawesome/fontawesome-free-solid
and @fortawesome/fontawesome-free-brands
) with npm
我安装
@fortawesome/angular-fontawesome
和两个依赖( @fortawesome/fontawesome-free-solid
和@fortawesome/fontawesome-free-brands
)与npm
I imported it in the app.module.ts
, and added it to the imports
: 我将其导入了
app.module.ts
,并将其添加到了imports
:
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
Did I miss something during the installation? 我在安装过程中错过了什么吗? I get no error on the terminal when I start the application using
ng serve --open
, I only get the error in the browser console. 使用
ng serve --open
启动应用程序时,在终端上没有任何错误,我仅在浏览器控制台中得到了错误。
I ran into the same error, only to realize that I had template values that didn't match the component names. 我遇到了同样的错误,只是意识到我的模板值与组件名称不匹配。
<button type="button" class="btn btn-default">
<fa-icon [icon]="caretLeft"></fa-icon>
</button>
When in my component, I had 在组件中,我有
private faCaretLeft = faCaretLeft;
It was a rookie mistake that stemmed from some renaming I did trying to troubleshoot previous errors. 这是一个菜鸟错误,源于我为解决先前的错误而进行的重命名。 When I changed the icon binding to the correct name, the error was resolved.
当我将图标绑定更改为正确的名称时,该错误已解决。
<button type="button" class="btn btn-default">
<fa-icon [icon]="faCaretLeft"></fa-icon>
</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.