Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <a href="https://somedomain.com/api/doc/somefile.pdf" ng-click="openPdf($event)">PDF</a>
- function openPdf($event) {
- // Prevent default behavior when clicking a link
- $event.preventDefault();
- // Get filename from href
- var filename = $event.target.href;
- $http.get(filename, {responseType: 'arraybuffer'})
- .success(function (data) {
- var file = new Blob([data], {type: 'application/pdf'});
- var fileURL = URL.createObjectURL(file);
- // Open new windows a show PDF
- window.open(fileURL);
- });
- }
Add Comment
Please, Sign In to add comment