I using openweathermap api to get json data, bu i need to get and use jsonp data for it, how to do this in my angular service ?
app.factory('forecast', ['$http', function($http) {
this.sendAPIRequest = function(city){
return $http.get('http://api.openweathermap.org/data/2.5/forecast/city?q='+city+'&units=metric&mo')
.success(function(data) {
return data;
})
.error(function(err) {
return err;
});
},
https://docs.angularjs.org/api/ng/service/$http#jsonp Demonstrates the proper way to use angular to receive JSONP objects.
The $http service call (from the AngularDocs) would look like:
While the markup binding this functionality is:
So basically your end result would be:
As seen here: parsing JSONP $http.jsonp() response in angular.js