[英]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.