我需要我的循環幫助。 我嘗試從Google Finance API獲取數據。 谷歌不提供multi-tiker API,因此每1個ticker提供1個請求。 對於1 ticker,它工作得很好,但我需要不止一個。 我嘗試做一個循環,但我得到角度環路
未定義[對象的對象] [對象的對象]在角
.controller('currency', function ($scope, $http){
var tickers =["EURUSD","AUDUSD];
for (i = 0; i < 2; i++) {
$http.get('https://www.google.com/finance/info?q=CURRENCY%3a'+tickers[i]).then(function successCallback(response) {
$scope.currencydata = $scope.currencydata + JSON.parse(response.data.substr(3));
})}
})
'$ http.get'是異步 – Satpal
使用$ q.all,對於所有的承諾 –
我認爲在 'VAR行情=「EURUSD」,「澳元兌美元缺少一個右引號「];' – Ernis