html - Angular:显示来自ngrx的fontawesome图标
问题描述
我在来自 API 的响应中保存了这样的图标字符串:
{
"icone": "fas fa-thermometer-half",
"cor1": "#FFF",
"cor2": "000"
}
在 Angular 10 应用程序中,我从 NGRX 商店获得。
public test$ = this.store.pipe(select(fromTest.getTest))
然后我尝试在 HTML 组件上呈现。
<ng-container *ngIf="test$ | async as tes">
<i class="{{tes[1].icone}}"></i>
</ngcontainer>
html的结果是:
<i _ngcontent-yaa-c157="" class="fa-thermometer-half fas"></i>
并且不显示...在 NGRX 商店,我可以看到这样的 icone 字符串: icone:"fas fa-thermometer-half" 我不知道为什么在渲染时会发生这种变化,但这不是问题所在。
解决方案
更改图标类绑定
<i class="{{tes[1].icone}}"></i>
至
<i [ngClass]="{{tes[1].icone}}"></i>
推荐阅读
- python-3.x - 排列组合
- python - Python 3 中基元类初始化函数的隐式调用
- python - 如何从 Flipkart 品牌过滤中选择复选框?我正在使用硒进行自动化。我想点击泰坦品牌过滤器
- tensorflow - 将类 tf.keras.Model 子类化以进行强化学习时的保存和构建问题
- sql-server - 备份压缩和固定文件名
- java - andThen 函数和 forEach 函数应用于流
- javascript - React:如何每 10 秒执行一次方法?
- reactjs - React 应用滚动到顶部仅适用于 Firefox
- ios - 是否有控制 HomePod 的 API?
- javascript - 为什么在使用 thunk 时以错误的顺序调用我的动作创建者?