blobDownload.js 791 B

123456789101112131415161718192021222324
  1. (function () {
  2. 'use strict';
  3. angular.module('ariaNg').directive('ngBlobDownload', ['ariaNgFileService', function (ariaNgFileService) {
  4. return {
  5. restrict: 'A',
  6. scope: {
  7. ngBlobDownload: '=ngBlobDownload',
  8. ngFileName: '@',
  9. ngContentType: '@'
  10. },
  11. link: function (scope, element) {
  12. scope.$watch('ngBlobDownload', function (value) {
  13. if (value) {
  14. ariaNgFileService.saveFileContent(value, element, {
  15. fileName: scope.ngFileName,
  16. contentType: scope.ngContentType
  17. });
  18. }
  19. });
  20. }
  21. };
  22. }]);
  23. }());