I have the below code to get json data and store it in a storage space in the device,I have tried the below code,
ionic.Platform.ready(function() {
$cordovaFile.createFile(cordova.file.applicationStorageDirectory, 'file.txt', true)
$ionicLoading.show();
$http.post("http://example.com/data/get_data").
success(function(data) {
//console.log(data);
$ionicLoading.hide();
$cordovaFile.writeFile(cordova.file.applicationStorageDirectory + 'file.txt', data, {
'append': false
}).then(function(result) {
alert('success');
}, function(err) {
// An error occured. Show a message to the user
console.log(JSON.stringify(err));
alert('failed');
});
})
.error(function(data) {
console.log("Request failed");
});
});
And it is showing an error in console like below :
4 238102 log Error in Success callbackId: File305293268 : TypeError: Object [object Object] has no method 'getFile'
5 238107 error Uncaught TypeError: Object [object Object] has no method 'getFile', http://192.168.2.86:8100/cordova.js, Line: 314
How to solve this?