【发布时间】:2017-05-10 08:44:49
【问题描述】:
<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”,则我正在尝试显示图像,则不应显示任何内容...它适用于字符串但不适用于数字..我不真的不明白为什么..
【问题讨论】:
-
您希望它同时处理字符串和数字吗?还是只有数字?
-
你有嵌套的双引号,这根本不起作用。试试
'1'。 -
只想使用数字作为 '0' = notthing 和 '1' = show img
-
我已经尝试了 '1' 但它不起作用
-
只用作
<img *ngIf="fooIcon === 1" src="./app/img/icones_sized/tick.png"/>
标签: angular typescript ngfor angular-ng-if