Chartjs-Then function not returning values Angular js

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.

Leave a comment