我遵循一个角度教程,并且由于自从教程制作后我必须在服务中使用的链接发生更改,我很困惑如何使用第二个params中的参数,这是api.openweathermap.org现在需要的appid。
function weatherFactory($http) {
return {
getWeather: function(city, country) {
var query = city + ', ' + country;
var key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
return $http.get('http://api.openweathermap.org/data/2.5/weather?', {
params: {
q: query,
appid: key
}
}).then(function(response) {
// //then() returns a promise which
// is resolved with return value of success callback
return response.data.weather[0].description;
});
}
};
}
链接应该是这样的:
http://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b1b15e88fa797225412429c1c50c122a1
所以我把喜欢在获得第二个PARAMS的关键,但我不知道如何在应用标识的前面加上这个&,以就像从他们的链接例子。 有人可以告诉我怎么做吗?
你的问题到底是什么? ,如何创建url?,如何添加params? –