【发布时间】:2021-07-06 22:31:06
【问题描述】:
我尝试了下面的代码来显示数据,如果没有数据它会显示一条消息。但它不起作用。
<ng-container *ngFor="let payment of orderTotals">
<ng-template *ngIf="payment?.length==0; else data">
<h4>No Data</h4>
</ng-template>
<ng-template #data>
<ion-card>
<ion-card-title>
<h4 class="ion-text-center" style="font-weight: bold">
{{payment.PaymentStatus}}
</h4>
</ion-card-title>
<ion-card-subtitle style="padding-left: 10px">
<h4 style="font-weight: bold">{{payment.Total | currency:'KWD '}}</h4>
</ion-card-subtitle>
</ion-card>
</ng-template>
【问题讨论】:
-
您检查的长度错误。
<ng-template *ngIf="orderTotals.length == 0"> <h4>No Data</h4> </ng-template>
标签: angular ionic-framework frontend angular8 rest