Created
October 25, 2014 19:55
-
-
Save hartzis/83b51a916fcd10f1908d to your computer and use it in GitHub Desktop.
iframe download file angular without jquery
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
.directive('fileDownload', function ($compile) { | |
var fd = { | |
restrict: 'A', | |
link: function (scope, iElement, iAttrs) { | |
scope.$on("downloadFile", function (e, url) { | |
// console.log('dl url-', url); | |
var iFrame = iElement.find("iframe"); | |
if (!(iFrame && iFrame.length > 0)) { | |
iFrame = angular.element("<iframe style='position:fixed;display:none;top:-1px;left:-1px;'/>"); | |
iElement.append(iFrame); | |
} | |
iFrame.attr("src", url); | |
}); | |
} | |
}; | |
return fd; | |
}); |
I'm using the same code, I have an issue when I want to download multiple files than previous download service call is getting canceled. I want same multiple downloaded. Did you face this issue
Code usage
then file download directive
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wondering why you need to inject $compile service into the directive, even though it was not used anywhere??