簡體   English   中英

角度微調隱藏功能不起作用

[英]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())
    );
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM