Tag: angularjs resource

在AngularJS中使用$ resource删除发布的内容

我是AngularJS的新手,尝试使用$ resource发布和删除内容。 我有张贴工作正常,但是当我尝试删除我已经张贴的东西,我得到一个404错误。 DELETE http://localhost:3000/tasks?__v=0&_id=53c5ddcf2978af0000ccdc50&beginningDat…vacy=true&title=This+is+a+complete+task&website=http:%2F%2Fwww.hotmail.com 404 (Not Found) 我一直在这个工作了几天,我只是没有看到我失踪。 我正在使用MEAN堆栈。 我在app.js中有mongoose,快车,bodyParser和cors作为依赖,并创build了我的terminal: app.get('/tasks', api.getTask); app.post('/tasks', api.postTask); app.delete('/tasks/:_id', api.deleteTask); 这里是我的api.js中的代码 exports.deleteTask = function(req, res){ var _id = req.params._id; Task.remove({_id:_id}, function(err, task){ res.send(task + ' removed task successfully'); if(err){ res.send('Hey guys…he is still here.'); } }); }; 这是我的工厂/服务: 'use strict'; angular.module('achievementApp').factory('tasks', function($resource){ return $resource('http://localhost:3000/tasks/',{_id: '@_id'},{ get: {method:'GET', isArray: […]