rob
March 10, 2014, 5:03pm
1
I’m using a service to return a promise for my data. Works fine in the browser but not in the simulator. Any ideas why?
Service Function:
var pets = [];
var pets_q = $q.defer();
return {
all: function() {
if (pets.length == 0) {
return $http.get('api/get_pets.php').then(function(response) {
pets = response.data;
pets_q.resolve(response.data);
return response.data;
});
}
return pets_q.promise;
}
}
Controller:
PetService.all().then(function(pets) {
$scope.pets = pets;
});
1 Like
rob
March 10, 2014, 5:35pm
2
Gah, figured it out. Had to do with an .htaccess on my web server. Very new to the the hybrid app world.
Also keep in mind that on iOS you have a whitelist on config.xml. It has to be configured to allow all (not good) or be locked down to specific domains.
Example :
<access origin="http://0.0.0.0:8080" />
1 Like
rob
March 11, 2014, 3:03pm
4
Thanks for the tip. I’ll get that setup.
biapar
March 23, 2014, 12:29pm
5
I made the same, but I’ve an error when put data into the scope. I read template from file.
Error on parent null.
same problem I can not find out any problem
origin=“http://0.0.0.0:8080 ” is it permission for all file