Resource factory:
.factory('WorkerRepository', function($resource){
return $resource('workers/:id', {id:'@id'});
})
Controller:
.controller('ListController', function($scope, WorkerRepository){
var workers = WorkerRepository.query(function(){
$scope.workers = workers;
});
$scope.worker = {nameSurname: 'Peter', email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f682938582b6919b979f9ad895999b">[email protected]</a>", phone: 600100200};
$scope.add = function() {
var worker = new WorkerRepository(this.worker);
worker.$save();
};
})
Upon executing the $scope.add
method, an unexpected
TypeError: Object #<g> has no method 'push'
error is thrown. Despite my understanding that the $resource
's $save
method lacks the 'isArray: true'
parameter by default, I am puzzled by the occurrence of this error message. Any insights on why this error persists?