Angularjs 平均堆栈删除

Angularjs 平均堆栈删除,angularjs,node.js,mongodb,mean-stack,Angularjs,Node.js,Mongodb,Mean Stack,尝试向我的帖子列表中添加一个删除按钮,该按钮将从数据库中删除条目,但仅在单击该按钮时返回null 我的$scope $scope.remove = function(post) { posts.remove(post); } 此功能的链接: o.remove = function(post) { $http({ url: '/posts/' + post._id, method: 'DELETE' }).then(f

尝试向我的帖子列表中添加一个删除按钮,该按钮将从数据库中删除条目,但仅在单击该按钮时返回null

我的$scope

$scope.remove = function(post) {
  posts.remove(post);
}
此功能的链接:

o.remove = function(post) {
    $http({ url: '/posts/' + post._id, 
            method: 'DELETE'                
    }).then(function(res) {
        // Deleted
        console.log(data);
        // Update list
        $http.get("/posts")
            .success(function(data, status, headers, config) {
              console.log(data);                
        });
    }, function(error) {
        console.log(error);
    });

 };
路由器:

router.delete('/posts/:post', function(req, res, next) {
        Post.remove({
            _id : req.params.id
        }, function(err, post) {
            if (err)
                res.send(err);

            Post.find(function(err, post) {
                if (err)
                    res.send(err)
                res.json(post);
            });
        });
    });
钮扣

    <span ng-click="remove(post)">
      Delete
    </span>
My console.log写入空值,不会删除任何内容。我非常感激能得到的所有帮助,因为我被困住了

你应该有:

_id : req.params.post
而不是:

_id : req.params.id
因为您在路由中有:post param:

router.delete('/posts/:post', function(req, res, next) {