I have a standard angular code that runs when a button is clicked:
$scope.downloadAll = function () { $http.get("download.php?id=" + $scope.id).success(function (data) { }).error(function () { $scope.status = "Error: can not download table data from server."; }); }
but my php script returns a zip archive, and its contents thus ends with a javascript variable, data strong>. I would like to change the behavior so that the zip archive is offered by the browser for storage on the local disk. How did I achieve this while retaining the angular button handler?
In your angular controller, enter $windowand use it like this:
$window
$scope.downloadAll = function () { $window.location.href = "/download.php?id=" + $scope.id; }
, zip http, (content-disposition, mime type,...).