Add a Slick Angular CSV Download Link

misc2Just thought I’d share this bit of code.  It allows an angular client app to create a csv file which can be used in a downloadable link that gets created on the client, on-the-fly, which the browser sees as an attachment:

// Create a downloadable link and click it.
$scope.SubmitFileToUser = function (csvData) {
var element = angular.element(‘<a/>’);
href: ‘data:attachment/csv;charset=utf-8,’ + encodeURI(csvData),
target: ‘_blank’,
download: ‘export.csv’

Update: If this doesn’t work for you, Aydin Akcasu came up with an alternative way to do it here.

One comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s