ngIf 取决于 Angular 4 中的数字绑定图像
ngIf with depending from number binding image in 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”是returning“1”,我正在尝试显示图像,如果它是return“0”,则不应显示任何图像...它适用于字符串但不是数字..我真的不明白为什么..
您应该使用 *ngIf...else
,因为
<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>
<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”是returning“1”,我正在尝试显示图像,如果它是return“0”,则不应显示任何图像...它适用于字符串但不是数字..我真的不明白为什么..
您应该使用 *ngIf...else
,因为
<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>