A simple task like downloading a file on the click of a link also sometimes proves so much challenging. There are some situations where we simply want to use it to download a document. Due to the default behavior of a modern browser which opens the document like PDF in a new tab. To add a custom name for the downloaded file, we can provide string value in the download attribute as shown below:.
To use in Angular, we can convert the href and download attributed to directives to take in dynamic values as shown below:. Here is my html code-. Why are you using so much coding for this , you can directly use download attribute of a tag.
NOTE : If your path is correct , you file will be downloaded otherwise it will be blank , same issue is in your code. Check your file path and make sure its correct. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow.
Learn more. How to download a pdf using fileSaver and Angular 2 Ask Question. Asked 4 years, 3 months ago. Active 4 years, 3 months ago. Viewed 4k times. What should I do? Subho Subho 5 5 gold badges 22 22 silver badges 44 44 bronze badges. Add a comment. Active Oldest Votes. Vivek Doshi Vivek Doshi I have 2 directories app and files in same level.
Show 1 more comment. Sign up or log in Sign up using Google.
0コメント