When I'm trying to create a new task, nothing happens and no request being sent. Why is that so? How can I debug the issue?
Here's $scope.add function
var app = angular.module('Tasks', ['ngResource', 'xeditable']);
app.factory('Task', [
'$resource', function($resource) {
return $resource('/tasks/:id', {
id: '@id'
}, {
update: {
method: 'PUT'
}
});
}
]);
this.TasksCtrl = [
'$scope', 'Task', function($scope, Task) {
$scope.add = function() {
var task;
task = Task.create($scope.newTask);
$scope.tasks.push(task);
return $scope.newTask = {};
};
];
Here's my html part.
<div ng-controller='TasksCtrl' class='tasks-container'>
<form ng-submit='add()'>
<input type='text' ng-model='newTask.title'/>
<button type='button' class='btn btn-default btn-sm'>
<span class='glyphicon glyphicon-plus'></span> Add
</button>
</form>
create-function you're adding aupdate-function to your resource class. Trytask = Task.update($scope.newTask);insteadupdate-function as a PUT request in your factoryTask