I am using ngCsv to try and export data to CSV. After clicking a button, I download all required data after which I would like to export it to CSV. However, I am getting a blank CSV for some reason. Below is the code for the button:
<button class="btn-primary" type="button" ng-csv="getAllData()" csv-header="['Order Number', 'Handling Code', 'Expected Date', 'Status', 'Reference', 'Loading Date', 'Unloading Date', 'Transaction Status']" filename="test.csv">Export to CSV</button>
The method I use to download the data:
$scope.getAllData = function () {
return ordersService.getAllOrders()
.success(function (data) {
return data.Items;
})
};
The getAllOrders method:
service.getAllOrders = function () {
return $http.get(ordersApiBase);
};
I've tried varoius other ways as can be seen here: Using ngCsv with an external API and here: https://github.com/asafdav/ng-csv/issues/58 yet I can't seem to figure out what I am doing wrong. Has anyone done something similar before?
console.log(data.Items)? And post the result?, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object…] [0 … 99] 0: Object ExpectedDate: "12/3/2015 12:00:00 AM" HandlingCode: "i" OrderNumber: "8500000007193" Reference: "PO-106993"ng-csvis not supporting nested objects.