你可以使用数组:
.controller('mycontroller', function($scope, $http, $q) { var urls = [ 'https://raw.githubusercontent.com/user/repo/master/first.json', 'https://raw.githubusercontent.com/user/repo/master/second.json', 'https://raw.githubusercontent.com/user/repo/master/third.json', 'https://raw.githubusercontent.com/user/repo/master/fourth.json', 'https://raw.githubusercontent.com/user/repo/master/fifth.json', 'https://raw.githubusercontent.com/user/repo/master/sixth.json' ]; var promises = urls.map(function(url) { return $http.get(url); }); $q.all(promises).then(function(data) { // data will represent an array containing the response from all // AJAX requests $scope.data = data; }); });
并在data
数组上的标记循环中: