我正在創建離子應用程序,我想要下載一個動態圖像,並使用cordova文件傳輸插件,但不工作時請檢查我犯的錯誤。Cordova文件傳輸插件
錯誤: - 網址沒有定義,無法讀取的不確定
$
scope.downloadImage = function() {
$http.get('http://sabkideal.com/phpapi_/cashback.php').success(function(response) {
$scope.data = response;
for (var i=0 ;i <response.length; i++)
{
var url = response[i].image;
var deal = response[i].id;
//url showing the same url every time i click and not jumping to next statement when click on send image download .
console.log(deal);
console.log(url);
var filename = url.split("/").pop ;
console.log(filename);
var targetPath = encodeURI(cordova.file.dataDirectory + fileName);
console.log(targetPath);
var options = {};
var trustHosts = true;
}
$cordovaFileTransfer.download(url, targetPath, options, trustHosts)
.then(
function(result) {
alert('Download success');
refreshMedia.refresh(targetPath);
},
function(err) {
alert('Error: ' + JSON.stringify(err));
},
function(progress) {
// progressing download...
})
});
}
你檢查什麼'response.image'返回? – sam
它的返回什麼都沒有.. undefined –
然後,也許你沒有正確解析響應。警告或記錄響應並正確遍歷圖像路徑 – sam