You can use the | async
pipe:
<div *ngIf="(list$ | async)?.length==0">No records found.</div>
Update – 2021-2-17
<ul *ngIf="(list$| async) as list; else loading">
<li *ngFor="let listItem of list">
{{ listItem.text }}
</li>
</ul>
<ng-template #loading>
<p>Shows when no data, waiting for Api</p>
<loading-component></loading-component>
</ng-template>
Update – Angular Version 6:
If you are loading up a css Skeleton you can use this. If the array has no items it will display the css template. If there is data then fill out the ngFor
.
<ul *ngIf="(list$| async)?.length > 0; else loading">
<li *ngFor="let listItem of list$| async">
{{ listItem.text }}
</li>
</ul>
<ng-template #loading>
<p>Shows when no data, waiting for Api</p>
<loading-component></loading-component>
</ng-template>