我需要添加元素,我以 JSON 格式将其作为 $scope.array 添加到数组中 我的代码是:
$scope.sections=function(){
$scope.array=[];
$http.get("/app/query/?mod=find&type=all").success(function(data){
$.each(data, function(i, row){
$scope.array.push('aaa');
console.log(row);
});
});
return $scope.array;
}
console.log($scope.sections());
但是这个函数返回空数组,我怎样才能添加元素$scope.array
?
此字符串将数据正确添加到控制台console.log(row);
,但$scope.array.push
不起作用