Factory http promise returns blank

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

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

Thanks for the tip. I’ll get that setup.

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