I am trying to download image using angular js. Please check my download function
$scope.downloadDocument = function (doc) {
console.log(doc.fileName);
$scope.array.nic = $stateParams.id;
$http({
method: "GET",
url: appConfig.apiUrl + "/downloadDoc/" + $scope.array.nic + "/" + doc.fileName
}).then(function (response) {
console.log(response);
$scope.downloadedImage = response.data;
if (response.status == 200) {
alertService.success("Document has been downloaded successfully.");
$scope.alerts = alertService.get();
}
else {
alertService.error(response.data.executionDescription);
$scope.alerts = alertService.get();
}
}, function (response) {
$log.log(response);
});
}
above GET request is success with 200 state. but file is did not download. I console log the response also. please check the below response.
this is my current download button
<button class="btn btn-success btn-flat btn-xs" type="button"
ng-disabled="document.submitted === false"
ng-click="downloadDocument(document)">
<i class="fa fa-download"> </i>
</button>
How i create download button using above response. can you help me for do it ? thanks