Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HTML
<div ng-controller="appController" ng-app="app">
    <a ng-href="C:\Users\mvijayan\Documents\Visual Studio 2015\Projects\AngularjsTraining\AngularjsTraining\Pdf\ID DocLink Programmer Reference.pdf" download="file.pdf">Hi guys, Please download this pdf file and start Your season</a>  
</div>


What I have tried:

hi friends,

i tried for download the pdf file using angularjs but its not working can anyone please tell me and if you know this please modify and reply me guys</pre>
Posted
Updated 6-Nov-16 0:16am

1 solution

Hi @User-11148958,

what do you mean by download is "not working"? I set up a quick example in Plunker[^] that uses pretty much your code. When I click the DOWNLOAD link, it opens the browser's default download dialog.

As your link does not contain any angular-specific statements (like e.g. {{/*...*/}}), you even should not need the ng-href for the download link, but stick with the plain HTML href hyper-reference attribute. See the docs[^] for more details and examples.

Just in case the Plunker link isn't working, this is the example code. To make the download link work, create an empty file, name it download.pdf and place it next to the HMTL file.

HTML
<!-- index.html -->
<!doctype html>
<html ng-app>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/css/bootstrap-combined.min.css">
  </head>
  <body>
    <div>
      <p><a href="download.pdf" download="file.pdf">DOWNLOAD</p>
  </body>
</html>


If you have any further questions, please let me know.

Best, K.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900