本文介绍了ngIf 依赖于 Angular 4 中的数字绑定图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
限时送ChatGPT账号.. <div *ngIf="user?.data.apps.details[0].acknowledged as fooIcon"><img *ngIf="fooIcon === "1" " src="./app/img/icones_sized/tick.png"/><img *ngIf="fooIcon === "0" " src="nothing_appears"/>
如果我的.acknowledged"返回1",我正在尝试显示图像,如果它返回0",则不应显示任何内容......它适用于字符串但不适用于数字......我不我真的不明白为什么..
解决方案你应该使用 *ngIf...else
, as
<img src="./app/img/icones_sized/stable_arrow_small.png"/></ng-模板><div *ngIf="user?.data.apps.details[0].acknowledged===1;else loading;"><img src="./app/img/icones_sized/tick.png"/>
<td *ngFor="let user of userService.users | async">
<div *ngIf="user?.data.apps.details[0].acknowledged as fooIcon">
<img *ngIf="fooIcon === "1" " src="./app/img/icones_sized/tick.png"/>
<img *ngIf="fooIcon === "0" " src="nothing_appears"/>
</div>
I am trying to display an image if my ".acknowledged" is returning "1" and if it return "0" nothing should be displayed...It works with a string but not with a number..I don't really understand why..
解决方案You should be using *ngIf...else
, as
<ng-template #loading>
<img src="./app/img/icones_sized/stable_arrow_small.png"/>
</ng-template>
<div *ngIf="user?.data.apps.details[0].acknowledged===1;else loading;">
<img src="./app/img/icones_sized/tick.png"/>
</div>
这篇关于ngIf 依赖于 Angular 4 中的数字绑定图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论