带有节点js的angular度js与$ http.post问题

我的angularjs $ http.post .then方法永远不会得到执行.catch方法执行虽然服务器工作正常,并返回我想要它返回。

这是我的节点js控制器,做电子邮件validation存在

module.exports.add = function(req, res, next) { var user = new User(req.body); User.find({email:req.body.email},function(err,doc){ if(err) { { err.status = 406; return next(err); } } if(doc.length){ return res.status(409).json({message: 'Email already exist'}); } else { user.save(function(err, doc) { if (err) { err.status = 406; return next(err); } return res.status(201).json({message: 'Your account has been created successfully. Please login to continue.'}); }) //end of user.save } //end of else }); }; 

这是我的angular度控制器

 quizApp.controller("createAcc",['$scope','$http','$location','$timeout','signup',function ($scope,$http,$location,$timeout,signup) { $scope.createAcc = function () { signup.createAcc($scope.fName, $scope.email, $scope.password) .then(function () { console.log("it happened"); }) .catch(function (err) { if(response.status === 409){ $scope.emailExist = true; } console.log("12345"); }); } } ]); 

这是我的angular色服务

 quizApp.factory('signup', ['$http',function ($http) { return { createAcc : function (fName,email,password) { var data = {fName:fName,email:email,password:password}; return $http.post('/api/v1/user/add',data) } } }]); 

所以现在的问题是,我的服务器正在做正确的validation,并发送给我的状态409即电子邮件存在,但在我的angularjs控制器.then函数或.catch函数永远不会运行。 在控制台中它只会引发409错误,但.then函数或.catch函数永远不会被执行。 我也试过.success(函数successCallback()},函数errorCallback(){}),也不起作用。 我不明白我在做什么错,一切工作正常邮递员(应用程序)虽然但我无法在这里debugging的问题。 我想我在我的angular码中做错了什么,任何人都可以告诉我为什么我的.then和.catch函数永远不会被执行?

也注入$q到工厂

更改

 ['$http','$q',function ($http) { 

 ['$http','$q',function ($http,$q) {