簡體   English   中英

在回調函數中可觀察到-角度5

[英]Observable in a callback function - angular 5

我正在嘗試執行一個回調,在該回調中,只有在收到響應后,才應從this.groupDefaultExpanded = -1;開始執行代碼行this.groupDefaultExpanded = -1; 之后。

 loadLoginDetails() {
    this.derivativeSpecService.getDerivativeDetails().subscribe(
        res => {
            this.rowData = res;
            this.groupDefaultExpanded = -1;
            this.getDataPath = function(data) {
              return data.orgHierarchy;
            };
              this.autoGroupColumnDef = {
              headerName: "Name",
            };

            console.log(this.rowData);
        })
      }

derivativespec.ts

 getDerivativeDetails(){

        return this.http.get('assets/derivativespec.json').map((response: Response) => response);
    }

像這樣:

getDerivativeDetails(): Promise<Response> {
    return this.http.get<Response>('assets/derivativespec.json').toPromise();
}

接着:

loadLoginDetails() {
    this.derivativeSpecService.getDerivativeDetails().then(
        res => {
            this.rowData = res;
            this.groupDefaultExpanded = -1;
            this.getDataPath = function(data) {
              return data.orgHierarchy;
            };
            this.autoGroupColumnDef = {
              headerName: "Name",
            };

            console.log(this.rowData);
    });
}

暫無
暫無

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

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