I have a simple scenario: I want to store an array returned from a service into a class variable. How do I wait for the data to be available until I store the data? It is a
You can just do it on complete() function. Doing that you will ensure that the data has arrived first.
getEventHistory(): void {
this.eventHistoryService.getEventHistory()
.subscribe(data => this.heatmapData = data,
error => console.log('Error in Heatmap get data: ' + <any> error),
() => console.log('HeatmapData: '+ this.heatmapData.toString());
);
}