Dont display categories until images are ready

This commit is contained in:
Zakary Timson 2018-07-12 17:05:29 -04:00
parent 10db284541
commit 2055c1f27b
2 changed files with 10 additions and 7 deletions

View File

@ -1,11 +1,13 @@
<div class="container">
<div class="row py-5">
<mat-card *ngFor="let c of categories | async">
<img mat-card-image [src]="c.image | async" [alt]="c.name">
<mat-divider class="custom-line"></mat-divider>
<mat-card-content>
<h3>{{c.name}}</h3>
</mat-card-content>
</mat-card>
<ng-container *ngFor="let c of categories | async">
<mat-card *ngIf="c.ready">
<img mat-card-image [src]="c.image | async" [alt]="c.name">
<mat-divider class="custom-line"></mat-divider>
<mat-card-content>
<h3>{{c.name}}</h3>
</mat-card-content>
</mat-card>
</ng-container>
</div>
</div>

View File

@ -18,6 +18,7 @@ export class CategoriesComponent {
map(rows =>
rows.map((row: any) => {
row.image = this.storage.ref(`${row.name.toLowerCase()}.jpg`).getDownloadURL();
row.image.subscribe(() => (row.ready = true));
return row;
})
)