Last active
December 18, 2015 22:34
-
-
Save ocReaper/29a9706b541b4d2443d3 to your computer and use it in GitHub Desktop.
Blob file download in Angular.js using $resource Part 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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() { | |
.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