In Angular applications, it is a common practice to use the ngIf directive with Observables to display data and provide an else template to show a placeholder while the data is loading.
<data-view *ngIf="data$ | async as data; else progress" [items]="data">
</data-view>
<ng-template #progress>
<mat-icon></mat-icon>
<mat-progress></mat-progress>
</ng-template>
However, this approach involves repetitive code for the else template, async pipe, and as clause. Is there a way to eliminate this boilerplate by using a custom directive like the following:
<data-view *ngWait="data$" items="data">
</data-view>
While I understand how to combine ngIf with the async pipe, I am struggling to figure out how to incorporate the else template into a custom directive.