Javascript $scope.myArrayOfObjects.push不是函数

Javascript $scope.myArrayOfObjects.push不是函数,javascript,angularjs,push,angular-material,Javascript,Angularjs,Push,Angular Material,我需要帮助。 我正在使用AngularJS和AngularMaterial。我尝试将对象推送到数组,但它会向我发送一条消息“$scope.myArrayOfObject.push不是函数” 我的代码: controller(“ClientesCTRL”、函数($scope、$http、$q、$timeout、$location、datosFactory、userFactory、$mdDialog){ $scope.clientes=[]; user=userFactory.getUser();

我需要帮助。 我正在使用AngularJS和AngularMaterial。我尝试将对象推送到数组,但它会向我发送一条消息“$scope.myArrayOfObject.push不是函数”

我的代码:

controller(“ClientesCTRL”、函数($scope、$http、$q、$timeout、$location、datosFactory、userFactory、$mdDialog){
$scope.clientes=[];
user=userFactory.getUser();
如果(用户){
$scope.selected=[];
$scope.query={
筛选器:“”,
命令:“发情”,
限额:5,
页码:1
};
var data={'op':1,'rut':user.rut};
$http.post('functions/ClientesCTRL.php',data)
.成功(功能(结果){
控制台日志(结果);
$scope.clientes=结果;
});
$scope.onpagechange=函数(第页,限制){
var deferred=$q.deferred();
$timeout(函数(){
延迟。解决();
}, 2000);
回报。承诺;
};
$scope.onorderchange=函数(顺序){
var deferred=$q.deferred();
$timeout(函数(){
延迟。解决();
}, 2000);
回报。承诺;
};
$scope.verContacto=函数(){
datosFactory.setClientContacto($scope.selected[0]);
$location.path(“/contactos”)
};
$scope.eliminarCliente=函数(ev){
//将对话框追加到document.body以覆盖docs应用程序中的sidenav
var confirm=$mdDialog.confirm()
.title(“Eliminar客户”)
.content('Estás seguro?'))
.ariaLabel(“幸运日”)
.目标事件(ev)
.ok('Eliminar'))
.取消(“取消”);
$mdDialog.show(confirm).then(function(){
警惕(“客户eliminado”);
},函数(){
});
};
$scope.addCliente=函数(ev){
$mdDialog.show({
控制器:AddClientController,
templateUrl:'addClienteForm.html',
父元素:angular.element(document.body),
目标事件:ev,
单击外部以关闭:true
})
.然后(函数(c){
控制台日志(c);
变量数据={'op':3,'cl':c,'user':user};
控制台日志(数据);
$scope.clients.push(c);
$http.post('functions/ClientesCTRL.php',data)
.成功(功能(结果){
如果(结果){
警惕(“客户阿格雷加多”);
$scope.clientes=[];
$scope.clients.push(c);
}否则{
警报(“阿格雷加客户错误”);
}
控制台日志(结果);
});
},函数(){
$scope.status='您取消了该对话框';
});
};
函数addClientController($scope、$mdDialog、$http){
$http.post(“functions/UsuarioCTRL.php”,{'op':14})
.成功(功能(结果){
如果(结果!==null){
$scope.formaspago=结果;
}
});
$scope.hide=函数(){
$mdDialog.hide();
};
$scope.cancel=函数(){
$mdDialog.cancel();
};
$scope.btnaddclient=function(){
$mdDialog.hide($scope.addCliente);
};
};
}

Agregar客户/Empresa
X
Rut客户/Empresa
拉松社会
化名为幻想曲
直接转帐
特莱福诺酒店
迪雷西翁
科穆纳
观察
付款方式
{{fp.forma}}
阿格雷加客户

您的数组可能不再是数组,您已经指向
clientes=results
,如果它不是数组,您需要将
results
推送到
clientes
中。
$scope.clientes.push(results)

还有,什么是“c”

您是否试图在
数据
对象中推送附加到
cl
的值

在这种情况下,您必须通过-
$scope.clientes.push(data.cl)


您确定$scope.clientes仍然是一个数组吗?

哪一行导致了$scope.clientes.push(c)问题;函数内部addcliente在$scope.clients上设置第二行数组,但它等于result later$scope.clientes=results;如果结果不是数组。谢谢,我将尝试您的代码是否可以在不做任何更改的情况下工作?或者它现在可以与建议的更改一起工作。。。?
  var data =  {'op':1, 'rut' : user.rut};
  $http.post('functions/ClientesCTRL.php', data)
  .success(function(results){
    console.log(results);
    $scope.clientes = results;
  });