I want to download a PDF from URL received via $http GET() request from the server. The $http is initiated as soon as a button is clicked on the front-end. On the success of the $http is receive a URL of where the PDF file is saved and want it to download automatically on the success of the $http request. How do I achieve this ?
EDIT:
Here's the HTML code:
<div class="button clearfix">
<button class="btn btn-primary pull-left m-b" ng-click="generateReport()">Download Report</button>
</div>
Here's my controller (Angularjs) code :
$scope.generateReport = function() {
$http.get('/pdfreport').success(function(response) {
$scope.url = response;
}).error(function(response) {
console.log("Failed");
});
}
I want to download file from $scope.url when the button is clicked