i've this factory thar call external api that return an array:
angular.module('starter.services', [])
.factory('PlacesService', function($http) {
var places = "";
var request = $http({
method: "get",
url: 'http://someurl/getPlaces.php'
});
request.then(function (data) {
places = data.response
});
console.log(places); // return empty string
return {
all: function() {
return places;
},
get: function(placesId) {
return places[placesId];
}
}
});
Places variable returned by http is an empty string. If I initialize places as an array and the I use places.push(data.response) it works, but return an array of array. Could you help me?