app.service('cityService',['$http',function($http){
this.cities = '';
this.get = function(){
$http({
method : 'get',
url : API_SERVER + 'city/'
}).success(function(response){
console.log(response);
return response;
}).error(function(response){
console.log(response);
});
};
}]);

I am trying to use the service to get the json data and i am able to get 
the data also but when i save the data inside a variable in controller....I 
am getting "Undefined" for value of the variable. I tried with $timeout() 
to wait till the request is complete but the problem is still the same. I 
tried .then() but it doesnt work with undefined.. :/ cityService.get() is 
getting undefined when i add .then() to it. What could be the possible 
problem coz the api call is working when i use the service but the response 
isn.t saving inside the variable. How can it be solved?

-- 
You received this message because you are subscribed to the Google Groups 
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to