這是我的服務角2個返回數據從訂閱
countGroupByEtat(): Observable<number[]> {
return this.http.get(this.url + 'GroupByEtat', { headers: this.prepareHeaders() })
.map((res: Response) => {
let object: Array<any> = [];
let jsonResults: Array<any> = res.json();
jsonResults.forEach((jsonResult) => {
object.push(jsonResult);
});
return object;
})
}
和我的方法
getGroupByEtat(): number[] {
this.serviceDossier.countGroupByEtat()
.subscribe((data: number[]) => {
this.objects = data;
console.log("subsc"+ this.objects)
})
return this.objects;
}
當我想要的subscribe
截止後,得到的this.objects
I的值接收一個數組,它是空,幫忙!
檢查'在方法返回this.object'和'在服務 – k11k2
返回object' @服務k11k2對象是全但this.object的方法=>在認購已滿,但沒有訂閱是空的 –