I'm pretty new to Angular 2, I have a site created which calls services but need to add a loading gif for each page or service call. Does anyone know how I can implement something like this?
Thanks
On your HTML you can write a spinner like the following:
<span *ngIf="isLoading">Loading...</span>
<span *ngIf="!isLoading">Result</span>
Before loading the service, probably on component load, you will have something like this on your component:
isLoading: Boolean = true;
Call the service on that component, subscribe to it, then change that boolean to true after the subscription has completed.
myService.subscribe(
result => {
// your other stuff here.
isLoading = false;
},
error => {
isLoading = false;
}