Hi skillnte,
You seem to forgot to return the promise from your get function.
app.service('cityService', ['$http', function ($http) {
this.cities = '';
this.get = function () {
return $http({ // <=== Notice the RETURN here!
method: 'get',
url: API_SERVER + 'city/'
}).then(function (response) { // dont' use the depricated .success
anymore'
console.log(response);
return response.data; // notice me adding the data part!
}).catch(function (response) {
console.log(response);
});
};
}]);
use it like:
cityService.get().then(r=> console.log(r))
Hope this helps you a bit,
Regards
Sander
--
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.