I am trying to use a JSON object living in a data.json file to be a dataset for a quick prototype I'm working on. This is located in the my_project/www/data/ directory. I have an Angular service that goes and captures data in this file using $http , does some things for this, and then is used throughout my application.
I use Cordoba and Ionic. When using ionic serve on my computer, everything looks perfect in the browser. However, when using ionic view ( http://view.ionic.io/ ) and opening the application on my iPad, I see:
{"data":null,"status":0,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"../data/items.json","headers":{"Accept":"application/json,test/plain,*/*}},"statusText":""}
for an answer. I would think that if this is a relative problem with the URL, this will not work in the browser either, but it is not.
That's what I'm doing:
config.xml has the following line:
<access origin="*" subdomains="true"/>
My service, which does a simple request preprocess, does:
return $http.get("../data/data.json").then(function (response) { return response.data; });
And finally, in my controller, I ask the service to fulfill the request:
myService.goGetData().then(onComplete, onError);
OnComplete () is called in my browser, and onError () is called on the iPad. Any guidance?