在您的模板中,您可以使用 *ngIf 显示加载微调器.component.tsthis.isLoading = false;onEvent() {this.isLoading = true;this.angularFirestore.collection('test').doc('testId').set(data).订阅(成功 =>{this.isLoading = false;}错误 =>{控制台日志(错误);this.isLoading = false;});}component.html<加载旋转器>Version infoAngular: 7 /Firebase: 5.7.3 /AngularFire: 5.1.1I tried to implement HttpInterceptor on angularfire2/Firestore API calls (Request URL: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=projects....) without success.The requests are not crossing the Interceptor as @angular/common/http/HttpClient is not used.Is there any workaround to integrate the Angular Interceptor functionality on those API calls?Thank you 解决方案 As far as i know AngularFire is a Angular friendly wrapper for the Firebase SDK.The Firebase SDK does not use Angular Http Client so API calls from the SDK can not be intercepted.For what use case do you want to intercept Firebase API calls?Edit:Here is a pseudo code example how i implement a simple loading spinner.On the event which starts the Firestore operation you could set isLoading to true and as soon as you get the response from Firestore you could set isLoading to fasle.In your template you could display a loading spinner with *ngIf.component.tsthis.isLoading = false;onEvent() { this.isLoading = true; this.angularFirestore.collection('test').doc('testId').set(data) .subscribe( success => { this.isLoading = false; } error => { console.log(error); this.isLoading = false; } );}component.html<div *ngIf="isLoading"> <loading-spinner></div> 这篇关于HttpInterceptor 不适用于 angularfire2/Firestore API 调用.任何解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-21 20:39