Answer the question
In order to leave comments, you need to log in
AngularJS: How to download a PDF from a link with a download attribute?
Good day.
Faced a problem, tell me the solution.
On the back - Laravel 5.x, on the front Angular 1.5.x (I use ui-router for routing on the front).
There are PDF files that are stored on the server in the stock_files folder . You need to make a link, by clicking on it the file should be downloaded. On windows, the option provided below works, on MacOS it is redirected to:
$urlRouterProvider.otherwise("/admin/redirecthome");
<a
ng-if="f.id"
ng-href="stock_files/{{vm.item.id}}/{{f.name}}"
download
target="_blank"
ng-bind="f.original_name">
</a>
, where vm.item.id is the id of the item, f.name is the file name. target="_blank"
$locationProvider.html5Mode(true);
<base href="/">
, Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question