Created
December 6, 2016 04:41
-
-
Save tosin2013/eb148c73ff0e3d45f6958302911a0514 to your computer and use it in GitHub Desktop.
ionic framework download image to device
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $scope.Download = function () { | |
| ionic.Platform.ready(function(){ | |
| var url = "http://3.bp.blogspot.com/-XchURXRz-5c/U5ApPOrPM9I/AAAAAAAADoo/YZEj4qeSlqo/s1600/Final-Fantasy-XV-Noctis-Red-Eyes.png"; | |
| var filename = url.split("/").pop(); | |
| var targetPath = cordova.file.externalRootDirectory + filename; | |
| $cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result) { | |
| console.log( 'Save file on '+targetPath+' success!'); | |
| }, function (error) { | |
| console.log('Error Download file'); | |
| alert("An error has occurred: Code = " + error.code); | |
| console.log("upload error source " + error.source); | |
| console.log("upload error target " + error.target); | |
| }, function (progress) { | |
| $scope.downloadProgress = (progress.loaded / progress.total) * 100; | |
| console.log($scope.downloadProgress ); | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment