ngIf with Angular 4中的依赖于数字绑定图像 [英] ngIf with depending from number binding image in Angular 4

查看:69
本文介绍了ngIf with Angular 4中的依赖于数字绑定图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <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> 

我正在尝试显示图像,如果我的".acknowledged"返回"1",并且如果返回"0",则什么也不显示.真的不明白为什么.

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..

推荐答案

您应该将 *ngIf...else 用作

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 with Angular 4中的依赖于数字绑定图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆