Created
February 8, 2019 10:39
-
-
Save vvscode/d69ebd7a35376d8336a0190e5397ad3c to your computer and use it in GitHub Desktop.
handle-api-call-state-nicely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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