I’m creating an Ionic App using the ngCordova FileTransfer plugin. I have it installed and setup. I have a click function in my view modeled to the function that should be downloading the file in my App. I am building my url and filename from data returned by a service.
When I tap the link, it pops open to a new “view” in the app which is the default state from my app.js file. I’m sure I’m missing something small. Can someone take a look at this and let me know if they see anything glaring?
$scope.showProgress = false;
$scope.downloadLink = function () {
var index;
var formLinks;
for (index = 0; index < $scope.formularyLookupDetails.length; index++) {
formLinks = $scope.formularyLookupDetails[index];
}
var filename = formLinks.LinkUrl.split("/").pop();
var targetPath = cordova.file.externalRootDirectory + filename;
var options = {};
var trustHosts = true;
$cordovaFileTransfer.download(formLinks.LinkUrl, targetPath, options, trustHosts).then(function (result) {
}, function (err) {
}, function (progress) {
$scope.showProgress = true;
$timeout(function () {
$scope.downloadProgress = (progress.loaded / progress.total) * 100;
});
});
};