When I need to push a new item in an empty array, I got an error : $scope.array.push is not a function.
But when the array is not empty, the push works perfectly and it correctly updates my scope.
For information, my array is instanciated like this :
$scope.array = [];
I tried too :
$scope.array = [{}]
How can I bypass this problem ? Or what am I doing wrong ?
EDIT :
$scope.urgences_hygienes = [];
$scope.save = function () {
$scope.newDemandeHygiene = {
id_zone : $scope.demandeHygiene.id_zone,
commentaire : $scope.demandeHygiene.commentaire,
date_demande : Math.round(new Date().getTime() / 1000)
}
$scope.urgences_hygienes.push( $scope.newDemandeHygiene );
$scope.reloadTable();
$modalInstance.close();
}