嗨,我是棱角分明的初学者,我想知道为什么当我从我的服务中调用它时,我得到一个空数组,这是我的代码:
var app = angular.module("myModule", ['ngResource']);
app.controller("myController", function ($scope,$http,$log,myService) {
$scope.users = []:
myService.query(function(data) {
$scope.users=data;
// all is fine, the length is 10 obj
console.log("users in: "+$scope.users.length);
});
//here i want to use my $scope.users array but the length is 0
console.log("users out: "+$scope.users.length);
});
关于如何处理这个问题的任何想法 提前谢谢。