简体   繁体   English

错误TypeError:无法读取未定义的属性“ html”(角字体)

[英]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.

相关问题 错误TypeError:无法读取undefined |的属性“0” Angular 4 - ERROR TypeError: Cannot read property '0' of undefined | Angular 4 Angular:ERROR TypeError:无法读取undefined的属性___ - Angular: ERROR TypeError: Cannot read property ___ of undefined 为什么Angular 5 Transition抛出AppComponent.html:2 ERROR TypeError:无法读取未定义的属性&#39;forEach&#39; - Why does Angular 5 Transition throw AppComponent.html:2 ERROR TypeError: Cannot read property 'forEach' of undefined 错误TypeError:无法读取未定义角度4的属性“地图” - ERROR TypeError: Cannot read property 'map' of undefined angular 4 Angular 5:错误类型错误:无法读取未定义的属性“toLowerCase” - Angular 5 : ERROR TypeError: Cannot read property 'toLowerCase' of undefined 角数组:错误类型错误:无法读取未定义的属性 - Angular array: ERROR TypeError: Cannot read property of undefined Angular “错误类型错误:无法读取未定义的属性‘匹配’” - Angular “ERROR TypeError: Cannot read property 'match' of undefined” 错误类型错误:无法读取未定义的属性“aDataSort”-ANGULAR 8 - ERROR TypeError: Cannot read property 'aDataSort' of undefined - ANGULAR 8 错误TypeError:无法读取Angular 4中未定义的属性&#39;setupScene&#39; - ERROR TypeError: Cannot read property 'setupScene' of undefined in Angular 4 在Angular应用上出现错误:TypeError:无法读取未定义的属性&#39;then&#39; - Getting error on Angular app: TypeError: Cannot read property 'then' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM