的REST API返回的restangular GET請求JSON對象和響應僅約在angularjs承諾的功能廣東話訪問restangular請求
Restangular.all('getUsers').getList().then(function(response) {
$scope.users = response;
angular.forEach($scope.users, function(value, key) { //This works
console.log(key + ': ' + value);
});
});
angular.forEach($scope.users, function(value, key) { //This does not work
console.log(key + ': ' + value);
});
'的GetList()'是異步。回調之外的'forEach()'在getList()返回並填充'$ scope.users'之前運行。 – 2014-09-30 06:33:58