Skip to content

Instantly share code, notes, and snippets.

@haohanyang
Last active August 3, 2023 11:55
Show Gist options
  • Save haohanyang/82c38bfb78131cdbdf6cc5ae5439bf6f to your computer and use it in GitHub Desktop.
Save haohanyang/82c38bfb78131cdbdf6cc5ae5439bf6f to your computer and use it in GitHub Desktop.
Fetch data in angular
<div *ngIf="fetchingError; else fetchingTemplate" class="alert alert-danger" role="alert">
{{ fetchingError }}
</div>
<ng-template #fetchingTemplate>
<div class="spinner-border text-primary" *ngIf="fetching; else dataTemplate" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<ng-template #dataTemplate>
<div class="row">
<app-word *ngFor="let word of words" [word]="word" class="col-md-6 col-lg-4 col-12 mb-2"></app-word>
</div>
</ng-template>
</ng-template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment