0
この場合、重大な問題があります。 以下のコードでgithub APIからデータを取得していますが、github alllowはページごとに30個の結果しか得られないため、より良いソートオプションを得るためにすべてのデータを取得し、オブジェクトの1つの配列にプッシュしたいと思います。以下は、この1つは複数のhttpコールの角度管理データ
$scope.getData = function() {
$http({
method: "GET",
url: api url + pageNum
}).then(function mySucces(response) {
$scope.mydata = response.data;
$scope.isLoading = false;
$scope.result = $scope.mydata.map(function (a) { return { 'name': a.name, 'html_url': a.html_url }; });
}, function myError(response) {
$scope.error = response.statusText;
});
};
正常に動作します。しかし、私はすべてのアイデアは、HWこれを行うには、この
$scope.getData = function() {
for(var i =0; i<= $scope.pages.length; i++){
$http({
method: "GET",
url: "apiUrl + i
}).then(function mySucces(response) {
$scope.mydata = response.data;
$scope.isLoading = false;
$scope.result = $scope.mydata.map(function (a) { return { 'name': a.name, 'html_url': a.html_url }; });
}, function myError(response) {
$scope.error = response.statusText;
});
};
ような何かをしたいコード を見つけますか?
すべての約束事を解決するために$ q.all()を使って同様のことを行っています。残念ながら、私はreposに今アクセスすることはできませんし、私は例を試すために自宅で必要なセットアップを持っていません。その方向を見てみてください。 –