Reputation: 41
I dumped a perfectly functional angularjs web app into cordova and compiled for ios. In testing for ios, if I try to access a local file from inside a callback response (from also accessing a local file for which I get a perfectly respectable 200) I get a 404. I changed it so both the initial request and the request from the callback are the same file. Still same error. If I change it to a remote url, it works fine. Code below:
function promiseFunc1() {
var wait = $q.defer();
$http.get('config/resources.json').success(function (data, status, headers, config) {
wait.resolve(data);
});
return wait.promise;
}
function promiseFunc2() {
var wait = $q.defer();
$http.get('config/resources.json').success(function (data, status, headers, config) {
wait.resolve(data);
});
return wait.promise;
}
promiseFunc1()
.then(function (result) {
return promiseFunc2()
})
.done()
Can someone point me in the right direction?
Upvotes: 2
Views: 474
Reputation: 3630
I think this is security in navigator (CORS) to access a file.
so you need to use API phonegap in the link :
http://docs.phonegap.com/en/2.5.0/cordova_file_file.md.html#File
Upvotes: 0
Reputation: 909
If your config
folder is outside www
then use
$http.get('../config/resources.json')
Upvotes: 1