【发布时间】:2019-07-20 19:07:26
【问题描述】:
我想在 ngfor 的帮助下显示数据库中的数据。我想用 ngif 来实现一些显示条件。
我的代码:
<ion-grid *ngFor="let chat of ChatListArray">
<ion-row *ngIf="chat.status == 'Incoming'">
<ion-col >
<div>
{{chat.msg}}
</div>
</ion-col>
</ion-row>
<br>
<ion-row *ngIf="chat.status == 'Outgoing'">
<ion-col >
<div>
{{chat.msg }}
</div>
</ion-col>
</ion-row>
</ion-grid>
但它不起作用。如何正确使用if语句请帮助。
{{chat.msg }} 不显示任何数据。 但在 ngif 之外它的作品。
我的 json 数组:
【问题讨论】:
-
您能fork this Sample StackBlitz 尝试复制您的问题吗?
-
你的
ChatListArray怎么样? -
@SiddAjmera 在我的情况下不起作用
-
你的 JSON 看起来很奇怪。它应该是一个对象数组(= 你的聊天),但它......不是真正的数组。
标签: angular ionic-framework ionic3 ionic4