This blog post covers how to use an AngularJS package to serve a csv download using JSON or array data. The only dependency that this package requires is ng-santize, which you can get the latest version here (or use the appropriate package manager). Let's start with getting ng-csv itself. You can download the package manually here, or you can do bower install ng-csv or npm install ng-csv Once you have the files locally, you can go ahead and add them to your angular dependencies. This means going to where you defined angular.module and adding both ngSanitize and ngCsv. An example would be var app = angular.module('myapp', ['ngSanitize', 'ngCsv']) After you have all your files and dependencies set up, you can go ahead and start using ng-csv. The key thing when it comes to ng-csv is placing the directive within a button element. The attribute of ng-csv should be equal to your json or array data. You also need to be sure to add a filename attribute. This is what the name of the file downloaded will be called. Also through in a type of button for this element. The finished button element should look like:
<button type="button" ng-csv="someDataVariableHere" filename="download.csv">Download</button>
Now when someone clicks, 'Download', they will have the csv downloaded to their computer! For more info and options on this package, the github page has good documentation.