I have a service that generates a CSV file and returns it to the page via http / ajax get. I would like the user to press a button, call a service call, and then upload the file to the user's browser.
I would like to do that. Angular Way, although I understand that this may have more to do with Ajax or the browser than Anuler itself.
The service is in C #, and this is what it returns:
return File(Encoding.UTF8.GetBytes(WriteCSV(assetList)), "text/csv", "results.csv");
The controller code that calls the service is as follows. It works, but I do not know what to do with success:
$scope.exportCSV = function () { $http({ method: "get", url: "ExportCSV" }). error(function (data, status, headers, config) { alert("Error exporting data to CSV."); }); };
source share