I want to conditionally show a block only if it contains data, otherwise I will show a noContent block. the data is fetched from the server.
<ng-container *ngIf="data$ async as data && data.payload; else noContent">
{{data.payload | json}}
</ng-container>
<ng-template #noContent> No content found </ng-template>
notes: 1- I dont want to implement two s, i.e:
<ng-container *ngIf="data$ async as data ; else noContent">
<ng-container *ngIf="data.payload; else noContent">
{{data.payload | json }}
</ng-container>
</ng-container>
...
2- the following statements are working
*ngIf="xx && yy"
*ngIf="data$ as data"
*ngIf="xx && data$ as data"
*ngIf="(data$ as data)?.payload?.length>0; else noContent"
Try like this
StackBlitz demo