如何使用$ resource.get()或$ http.get()参数

时间:2017-03-02 18:55:13

标签: angularjs

我遵循了一个使用api.openweathermap.org进行天气应用课程的角度教程。由于openweathermap.org不再有超过1天的天气数据,我找到了另一个网站,可让您免费获得超过1天的天气数据。

问题是我无法弄清楚如何在$ resource.get()内的教程链接中实现新的demo链接。

api.openweathermap.org的代码:

使用$ resource

$scope.weatherAPI = $resource("http://api.openweathermap.org/data/2.5/weather?");
$scope.key = 'sdfdfdsfdsfsdfrtrt';
$scope.weatherResult = $scope.weatherAPI.get({q: $scope.city, appid: $scope.key});

使用$ http:

var query = city + ', ' + country;
$http.get('http://api.openweathermap.org/data/2.5/weather?', {
params: {
    q: query,
    appid: key
}

输出:

openweathermap.org/data/2.5/weather?q=Boston,usa&appid=xddfdfreredfwsere

来自api.wunderground.com的新链接

http://api.wunderground.com/api/xfgfgffgghghrer/forecast/q/CA/San_Francisco.json

我的问题是在openweathermap之后?你可以轻松使用你的params,但在wunderground你有很多/​​ /分开params。

到目前为止,我已经达到了这一点,但是不起作用:

$resource("http://api.wunderground.com/api/appid/forecast/q")

有人可以用$ resource或$ http给我一个帮助吗?

0 个答案:

没有答案
相关问题