0👍
The .then
function returns a promise, meaning that it waits for async tasks to be finished and executes it’s callback function when it’s done. It still continues to execute further code down the road.
Angulars $http
service returns a promise which gets resolved when the async call to contarAreasInteres
is done or fails due to an error. So it makes sense that outside of .then
your console.log
prints undefined
because there was yet no data received.
Here is an explanation why promises are important and how they work.
- Chartjs-How to show tooltip over colored/stacked region of stacked line chart in chartjs?
- Chartjs-Using and reading a variable from Knockout.js in Chart.js
Source:stackexchange.com