繁体   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