Your backend needs to communicate the file's location to the front-end so that a link to the file can be created. It's recommended for the backend to generate a unique hash name for each file. The file can be retrieved through a Rest GET request as long as the backend webserver has the appropriate mime types set up.
To retrieve the file path, you would make a call to a service in your controller:
SomeController.$inject = ['$http'];
var SomeController = function($http) {
var self = this;
$http.get('/download-file-path').then(function(path) {
self.path = path;
}
}
Then, in your view:
<div ng-controller='SomeController as vm'>
<a ng-href="{{vm.path}}">Download</a>
</div>
When Angular calls GET: /download-file-path
, the backend should return the file's name and path, such as /download/file-7dje79ae.xml
. Angular will then populate the path in the a
link. Upon clicking the download button, the user's browser will request /download/file-7dje79ae.xml
and begin downloading the file.