从$ cordovaFileTransfer.download(url,targetPath,{},true)下载的图像在离子中未显示在ios中

时间:2018-01-22 06:25:57

标签: ios image cordova ionic-framework

我在ios中使用cordovaFileTransfer.download(url, targetPath2, {}, true)下载了一个图片。它显示成功,但图像在设备上不可用。如何解决此问题。

这是我的代码: -

$scope.Download = function () {
      ionic.Platform.ready(function(){
             var url = "https://www.google.co.in//images/branding/googlelogo/2x/googlelogo_color_120x44dp.png";
             var filename = url.split("/").pop();
             var targetPath2 = cordova.file.dataDirectory + 'Pictures/' +  filename;
              alert(targetPath2);
              $cordovaFileTransfer.download(url, targetPath2, {}, true).then(function (result) {
                    alert(JSON.stringify(result));
                    $scope.hasil = 'Save file on '+targetPath2+' success!';
                    $scope.mywallpaper=targetPath2;
                    alert( $scope.hasil);
                    alert($scope.mywallpaper);
              }, function (error) {
                    $scope.hasil = 'Error Download file';
              }, function (progress) {
                    $scope.downloadProgress = (progress.loaded / progress.total) * 100;
                    alert("dom"+$scope.downloadProgress);
              });
      });
  }

0 个答案:

没有答案