What im trying to achieve :
When the user clicks on a image placeholder the image is downloaded from the server to the device (to a specific location) , the downloaded image path is then stored in the $socpe and displayed to the user .
Below is my contorler
.controller('NDetailCtrl', function($scope, $state,$stateParams,$ionicLoading,$ionicHistory,$timeout,$cordovaFile,$cordovaFileTransfer) {
$scope.image = '';
// triggered on click
$scope.downloadFile = function(image) {
var url = "http://app.example.org/uploads/"+image ;
var filename = url.split("/").pop();
var targetPath = cordova.file.externalRootDirectory+filename;
var trustHosts = true;
var options = {};
$cordovaFileTransfer.download(url, targetPath, options, trustHosts)
.then(function(result) {
// Success!
console.log(JSON.stringify(result));
$scope.resource = result.nativeURL;
// This return the file location as
// file:///storage/emulated/0/[filename]
$scope.image = true;
console.log($scope.resource);
}, function(error) {
// Error
alert('Error : Some Thing went wrong !');
}, function (progress) {
$timeout(function () {
$scope.downloadProgress = (progress.loaded / progress.total) * 100;
});
});
};
})
I have whitelist config as well this one is inserted inside diviceready event
$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|file|blob|cdvfile|content):|data:image\//);
When i try to load the returned path using ng-src it doesn’t display any thing , just a blank white space .