我是angularjs中的新成員,我想通過angularjs獲取多個城市的數據。如何在angularjs中使用openweathermap api獲取多個城市的數據?
這裏是代碼:
var app = angular.module('jsbin', []);
app.controller('DemoCtrl', function($http) {
var vm = this;
var vm1 = this;
var URL = 'http://api.openweathermap.org/data/2.5/forecast/daily';
var request = {
method: 'GET',
url: URL,
params: {
q:'',
mode: 'json',
units: 'imperial',
cnt: '7',
appid: '4e1869d8da618fde99e84483*******'
}
};
$http(request)
.then(function(response) {
vm.data = response.data.list ;
console.log(response.data);
}).
catch(function(response) {
vm.data = response.data;
});
});
那麼問題是什麼?你已經知道如何去做。 – dfsq
但是在這裏,我只獲取一個城市的數據,但我想要多個城市的數據。 – jesusverma