I can't resolve my problem - create link to download attachment.
A file I receive from SOAP service in xml and consequently I must create a link to download file.
What I have now:
In controller:
//creating comments
for (var index in $scope.comments){
var com = $scope.comments[index]
if (com.z2AF_Work_Log01_ attachmentName !==undefined){
var a = document.createElement('a');
a.target = '_blank';
a.download = com.z2AF_Work_Log01_ attachmentName;
a.innerText = com.z2AF_Work_Log01_ attachmentName;
var blob = new Blob([atob(com.z2AF_Work_Log01_ attachmentData) ],
{ type : 'zip' });
//com.href = (window.URL || window.webkitURL). createObjectURL( blob );
a.href = (window.URL ||window.webkitURL).createObject URL( blob );;
com.attachment_link = a.outerHTML;
}
}
Links created, but if I have not plain text (csv) a file after download is broken. When I download csv - all fine.
In template:
.attach ng-bind-html="comment. attachment_link | notSanit"
Thanks.
댓글 없음:
댓글 쓰기