I have download text file request from backend. I need to download the file by posting get request given in service.js but the problem is I am getting %7d %7d in blank when I am downloading the file. Need assistance.I even tried with ng-href, still no luck
HTML:
<button class="btn btn-info" ng-click="downloadAllExhibitors();">
<a href="{{newFile}}" target="_blank">Download</a></button>
JS:
$scope.downloadAllExhibitors = function () {
$scope.newFile = service.downloadExhibitor();
}
Service.js
var url =' http://localhost/1290/';
function downloadExhibitor() {
var token = 129821sahh;
var auth = "Token" + ' ' + token;
var config = {
headers: {
'Content-Type': 'application/json',
'Authorization': auth
}
}
return $http.get(url + 'entity/campaigns/download_exhibitors/', config);
}
$http.getreturns a Promise. Tryservice.downloadExhibitor().then((res) => {$scope.newFile = res.data;}). Also your%7d %7dare URL encoded}}application/jsonif it is a text file? Why are you setting thehrefattribute with{{ }}interpolation if the data is JSON?