Skip to content

Instantly share code, notes, and snippets.

@ocReaper
Last active December 18, 2015 22:34
Show Gist options
  • Save ocReaper/29a9706b541b4d2443d3 to your computer and use it in GitHub Desktop.
Save ocReaper/29a9706b541b4d2443d3 to your computer and use it in GitHub Desktop.
Blob file download in Angular.js using $resource Part 3
/* global URL */
(function () {
'use strict';
angular
.module('app')
.controller('EmailCtrl', EmailCtrl);
function EmailCtrl($scope, Email) {
var vm = this
, downloadableBlob = '';
vm.getUploadedFileUrl = function getUploadedFileUrl() {
return downloadableBlob;
};
$scope.$on('$stateChangeSuccess', updateDownloadableBlob);
function updateDownloadableBlob() {
Email
.getFile({
emailId: 1,
fileName: 'some.xlsx'
})
.$promise
.then(function (data) {
downloadableBlob = URL.createObjectURL(data.response);
});
}
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment