我想在我的Angular项目中使用fontawesome。我想尝试使用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)我使用npm安装了@fortawesome/angular-fontawesome和两个依赖项(@fortawesome/fontawesome-free-solid和@fortawesome/fontawesome-free-brands
我将其导入app.module.ts,并将其添加到imports中
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';我是不是在安装过程中遗漏了什么?当我使用ng serve --open启动应用程序时,我在终端上没有得到任何错误,我只在浏览器控制台中得到错误。
发布于 2018-02-10 03:50:54
我遇到了同样的错误,只是意识到我的模板值与组件名称不匹配。
<button type="button" class="btn btn-default">
<fa-icon [icon]="caretLeft"></fa-icon>
</button>在我的组件中,我有
private faCaretLeft = faCaretLeft;这是一个新手错误,源于我在尝试解决之前的错误时所做的一些重命名。当我将图标绑定更改为正确的名称时,错误被解决了。
<button type="button" class="btn btn-default">
<fa-icon [icon]="faCaretLeft"></fa-icon>
</button>https://stackoverflow.com/questions/48696978
复制相似问题