Angularjs: Send Files To Download In Firefox
I am attempting to download several PDF files when clicking on a button. My current code is working fine in Chrome, but I cannot get it to work in Firefox. angular.forEach(download
Solution 1:
I have a similar Angular download and what's working here is:
var blob = newBlob([response.data], {type: "application/pdf"});
var blobURL = window.URL.createObjectURL(blob);
if (window.navigator.msSaveOrOpenBlob) {
// of course, IE needs special hand-holding....window.navigator.msSaveOrOpenBlob(blob, 'something.pdf');
} else {
window.open(blobURL);
Please make absolutely sure you are not blocking popups from the site, that has tripped me several times on various browsers.
Solution 2:
I used an IFrame to download. Just pass an url to this function to download.
$scope.downloadUrl = function (url) {
var oIframe = window.document.createElement('iframe');
var$body = $(document.body);
var$oIframe = $(oIframe).attr({
src: url,
style: 'display:none;'
});
$body.append($oIframe);
$scope.actions++;
};
Then you can call as
$scope.downloadUrl('/data/url/goes/here');
Post a Comment for "Angularjs: Send Files To Download In Firefox"