this is my service
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;
})
}
and my method
getGroupByEtat(): number[] {
this.serviceDossier.countGroupByEtat()
.subscribe((data: number[]) => {
this.objects = data;
console.log("subsc"+ this.objects)
})
return this.objects;
}
When I want to obtain the value of this.objects
after the closing of subscribe
I receive an array that is empty, help !