[英]Angular: Showing a fontawesome icon from ngrx
I am saving an icon string like this on my response from API:我在 API 的响应中保存了这样的图标字符串:
{
"icone": "fas fa-thermometer-half",
"cor1": "#FFF",
"cor2": "000"
}
At Angular 10 application I get from NGRX store.在 Angular 10 应用程序中,我从 NGRX 商店获得。
public test$ = this.store.pipe(select(fromTest.getTest))
Then I try to render at HTML component.然后我尝试在 HTML 组件上呈现。
<ng-container *ngIf="test$ | async as tes">
<i class="{{tes[1].icone}}"></i>
</ngcontainer>
The result at html is: html的结果是:
<i _ngcontent-yaa-c157="" class="fa-thermometer-half fas"></i>
And doenst show... At NGRX Store I can see the icone string like this: icone:"fas fa-thermometer-half" and I dont know why this change when rendered, but isnt the problem.并且不显示......在NGRX商店我可以看到这样的icone字符串:icone:“fas fa-thermometer-half”,我不知道为什么渲染时会发生这种变化,但这不是问题。
Change icon class binding from从更改图标类绑定
<i class="{{tes[1].icone}}"></i>
To到
<i [ngClass]="{{tes[1].icone}}"></i>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.