I am trying to download pdf file under my project folder (\src\app\files\pdf\iBATIS.pdf) when clicking the button. When clicking button, [Failed- no file] is shown and no file is downloaded. What do I need to do to be able to download this file? Could you please help me.

When I moved the pdf file under (\src\assets) folder, the pdf file is successfully downloaded. Why the file cannot be downloaded under (\src\app\files\pdf\iBATIS.pdf)?


        button type="button" (click)="downloadPDF()" => Click button

    ts ( ts file path is src\app\pdfdownload\pdfdownload.component.ts)
            let link=document.createElement("a");

1 Answers

Dupinder Singh On

*, First of all, * according to my knowledge, asset folder in the project is given to access data and download stuff.

If the file is already on the server, then you can try these following ways to download:

f1() {
    window.open('path', '_blank');


f1() {
   window.open('/assets/files/blabla.pdf', '_blank');


<a download="filename" target="_blank" href="/assets/files/blabla.pdf">
  Click here to download image

and if you want to do this in angular then I think you should try $http method of angular like following

$http({method: 'GET', url: '/someUrl'}).
  success(function(data, status, headers, config) {
     var anchor = angular.element('<a/>');
         href: 'data:attachment/csv;charset=utf-8,' + encodeURI(data),
         target: '_blank',
         download: 'filename.csv'

  error(function(data, status, headers, config) {
    // handle error

might this work for you!!!