Reputation: 1613
I want to use $cordovaFileTransfer in my app to dowload image data, but after trying to implement the code, this error is showing up:
Cannot read property 'download' of undefined
here is my code:
var url = "blablabla.com/img.png";
var targetPath = "img/"+ imgpaths;
var trustHosts = true;
var options = {};
$cordovaFileTransfer.download(url, targetPath, options, trustHosts)
.then(function(result) {
// Success!
console.log('Download Success' + targetPath);
}, function(err) {
// Error
}, function (progress) {
$timeout(function () {
var downloadProgress = (progress.loaded / progress.total) * 100;
console.log('Progress : '+downloadProgress);
});
});
anybody can help me?
Upvotes: 1
Views: 625
Reputation: 17647
Check this issues list: http://ngcordova.com/docs/common-issues/
For example have you wrapped the call to $cordovaFileTransfer.download()
inside deviceready
handler or better inside $ionicPlatform.ready()
?
Upvotes: 0