ngIf with depending from number binding image in A

2019-09-07 19:14发布

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

1条回答
唯我独甜
2楼-- · 2019-09-07 19:36

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>
查看更多
登录 后发表回答