Angular 微调器隐藏功能不起作用
Angular Spinner Hide Function Doesn't Work
在我的应用程序中,我有一个微调器,它会在 GET
功能完成后停止。对于一个屏幕,即使 GET
功能看起来在网络中完成,微调器也不会隐藏。计数器永远不会变为 0。可能是什么问题?
旋转器服务:
private _spinner: FuseSpinnerComponent;
private _callCount: number = 0;
public hide(): void {
this._callCount--;
if (this._spinner && this._callCount <= 0) {
this._spinner.Hide();
}
}
HTTP 服务:
get(url: string, contentType?: ContentTypes): Observable<any> {
this._spinner.show();
return this._http.get(this.baseUri + url, { headers: this.getHeader(contentType) }).pipe(
catchError((err: any) => this.handleError(err)),
finalize(() => {
this._spinner.hide();
}),);
}
屏幕:
if (state.url.indexOf("/admin/contact-list") >= 0) {
return new Promise((resolve, reject) => {
Promise.all([
this.getContactList(),
this.getGeoTypeList(),
this.getSectorTypeList(),
]).then(
([results]) => {
resolve([]);
},
reject
);
});
}
getContactList() {
return new Promise((resolve, reject) => {
this._http
.get("Crm/GetContactList/")
.subscribe((response: IContact[]) => {
this.contactList = response;
this.onContactListChanged.next(
this.contactList
);
resolve(this.contactList);
}, reject);
});
}
getGeoTypeList(): Observable<IGeoType[]> {
return this._http.get("Parameter/GetGeoTypeList");
}
getSectorTypeList(): Observable<IGeoType[]> {
return this._http.get("Parameter/GetSectorTypeList");
}
Http客户端请求很冷,需要订阅才能获取数据
get(url: string, contentType?: ContentTypes): Observable<any> {
this._spinner.show();
return this._http.get(this.baseUri + url, { headers:
this.getHeader(contentType) }).pipe(
catchError((err: any) => this.handleError(err)),
}).subscribe( _ => this._spinner.hide())
);
}
在我的应用程序中,我有一个微调器,它会在 GET
功能完成后停止。对于一个屏幕,即使 GET
功能看起来在网络中完成,微调器也不会隐藏。计数器永远不会变为 0。可能是什么问题?
旋转器服务:
private _spinner: FuseSpinnerComponent;
private _callCount: number = 0;
public hide(): void {
this._callCount--;
if (this._spinner && this._callCount <= 0) {
this._spinner.Hide();
}
}
HTTP 服务:
get(url: string, contentType?: ContentTypes): Observable<any> {
this._spinner.show();
return this._http.get(this.baseUri + url, { headers: this.getHeader(contentType) }).pipe(
catchError((err: any) => this.handleError(err)),
finalize(() => {
this._spinner.hide();
}),);
}
屏幕:
if (state.url.indexOf("/admin/contact-list") >= 0) {
return new Promise((resolve, reject) => {
Promise.all([
this.getContactList(),
this.getGeoTypeList(),
this.getSectorTypeList(),
]).then(
([results]) => {
resolve([]);
},
reject
);
});
}
getContactList() {
return new Promise((resolve, reject) => {
this._http
.get("Crm/GetContactList/")
.subscribe((response: IContact[]) => {
this.contactList = response;
this.onContactListChanged.next(
this.contactList
);
resolve(this.contactList);
}, reject);
});
}
getGeoTypeList(): Observable<IGeoType[]> {
return this._http.get("Parameter/GetGeoTypeList");
}
getSectorTypeList(): Observable<IGeoType[]> {
return this._http.get("Parameter/GetSectorTypeList");
}
Http客户端请求很冷,需要订阅才能获取数据
get(url: string, contentType?: ContentTypes): Observable<any> {
this._spinner.show();
return this._http.get(this.baseUri + url, { headers:
this.getHeader(contentType) }).pipe(
catchError((err: any) => this.handleError(err)),
}).subscribe( _ => this._spinner.hide())
);
}