I want the Task.save function to redirect to /users/:user_id/tasks
, but it is currently pointing to the wrong path and I am encountering the following error:
No route matches [POST] "/users/tasks"
Any suggestions on how to resolve this issue? Thank you in advance.
js
var app = angular.module('Todolist', ['ngResource', 'xeditable']);
app.factory('Task', [
'$resource', function($resource) {
return $resource('users/:user_id/tasks/');
}
]);
app.controller('TasksCtrl', [
'$scope', 'Task', function($scope, Task) {
$scope.addNewTask = function() {
var task = Task.save($scope.newTask);
$scope.tasks.push(task);
$scope.newTask = {};
};
}
]);