Skip to content

Instantly share code, notes, and snippets.

@vvscode
Created February 8, 2019 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vvscode/d69ebd7a35376d8336a0190e5397ad3c to your computer and use it in GitHub Desktop.
Save vvscode/d69ebd7a35376d8336a0190e5397ad3c to your computer and use it in GitHub Desktop.
handle-api-call-state-nicely
@Component({
selector: 'loading-container',
template: `
<div *ngIf="loadable.loading">This is loading spinner...</div>
<div *ngIf="loadable.error">{{loadable?.error?.message || 'Something went wrong'}}</div>
<ng-container *ngIf="loadable.success">
<ng-content></ng-content>
</ng-container>
`
})
export class LoadingContainerComponent {
@Input() loadable: Loadable;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment