首页 新闻 赞助 找找看

关于ionic angularjs 如何将图片保存到ios图库?

0
悬赏园豆:50 [已解决问题] 解决于 2017-06-26 15:22

我是用了ngCordova插件,ng-cordova.js,cordova.js都引用了,模块也注入了ngCordova,控制器也注入了$cordovaFileTransfer,但是以下代码在虚拟ios环境没有响应:

 1 //  下载图片
 2 $scope.downloadImg = function () {
 3     var url = $scope.imageUrl;
 4     var filename = url.split("/").pop();
 5     alert(filename);
 6     var targetPath = cordova.file.documentsDirectory + filename;
 7     var trustHosts = true;
 8     var options = {};
 9     alert(cordova.file.documentsDirectory);
10     $cordovaFileTransfer.download(url, targetPath, options, trustHosts)
11         .then(function(result) {
12           //  success!
13 alert(JSON.stringify(result));
14         }, function(err) {
15           //  error
16 alert(JSON.stringify(err));
17         }, function (progress) {
18           $timeout(function () {
19             $scope.downloadProgress = (progress.loaded / progress.total) * 100;
20           })
21         });
22   }

不知道为什么,求教大神

luoyezhiqiu630的主页 luoyezhiqiu630 | 初学一级 | 园豆:162
提问于:2017-01-04 17:41
< >
分享
最佳答案
0

ngCordova 没用过。但是ios 自带的保存到图库的方法的

收获园豆:50
青语 | 小虾三级 |园豆:1000 | 2017-01-11 09:34

ngCordova没有解决,最后是将image url传给ios,通过ios自带的保存到图库。

luoyezhiqiu630 | 园豆:162 (初学一级) | 2017-01-14 13:47

@luoyezhiqiu630: 对的,通过url获取到图片 也是可以保存的。

青语 | 园豆:1000 (小虾三级) | 2017-01-16 09:49
其他回答(1)
0

通过url获取到图片 也是可以保存的。

luoyezhiqiu630 | 园豆:162 (初学一级) | 2017-06-22 15:57
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册