i want an alternate to angular 1 $http.pendingRequest in Angular 2 or any thing to track globally like interceptors. Mainly for showing a loading icon while calls are been made
I would probably just maintain the state of the icon while the observable has not returned.
Example:
export class MyClass {
private isLoaded = false;
constructor(private myService: MyService){}
ngOnInit(){
this.myService.myServiceCall().subscribe(data => {
console.log(data);
this.isLoaded = true;
});
}
}
Then use *ngIf
on the dialog. You can also consider using the async pipe that Angular provides for scenarios like this:
https://angular.io/docs/ts/latest/api/common/index/AsyncPipe-pipe.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With