When attempting to add a new item to an empty array, I encounter an error: $scope.array.push is not a function.
However, when the array is not empty, the push operation works flawlessly and updates my scope correctly.
Just so you know, my array is initialized like this:
$scope.array = [];
I also attempted:
$scope.array = [{}]
How can I resolve this issue? What am I doing incorrectly?
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();
}