Then it works as expected. However, if I define it by this:
$scope.getCSVResultsData = function () {
var promises = … // Build an array of promises, each returning a row
return $q.all(promises)
.then(function(arr) {
console.log(arr)
return arr
})
};
Then I don’t get a CSV file, even though the data logged in the console is the same.
The only difference I can see is that in the first case the promise has the data available immediately, and in the second it is really asynchronous. I presume this should work? If so, any idea why it isn’t for me?
I’m having problems getting promises working with ng-csv
So my HTML looks like this:
<button ng-csv="getCSVResultsData()" filename=“results.xslx">Results</button>
If my getCSVResultsData function looks like this:
Then it works as expected. However, if I define it by this:
Then I don’t get a CSV file, even though the data logged in the console is the same. The only difference I can see is that in the first case the promise has the data available immediately, and in the second it is really asynchronous. I presume this should work? If so, any idea why it isn’t for me?