title: Angular POST request not working
body: <p>I've setup a signup and login system using passport.js. And Im using Angular.js in the front-end. But when I use angular it does not signup my users. Without angular it works well. See code below:</p>
  
  <p><strong>Without Angular Code (It works):</strong></p>
  
  <pre><code>&lt;form action="/signup" method="post"&gt;
      &lt;div class="form-group"&gt;
          &lt;label&gt;Email&lt;/label&gt;
          &lt;input type="text" class="form-control" name="email"&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label&gt;Password&lt;/label&gt;
          &lt;input type="password" class="form-control" name="password"&gt;
      &lt;/div&gt;
  
      &lt;button type="submit" class="btn btn-warning btn-lg"&gt;Signup&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>With Angular Code (Does Not Work):</strong></p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html ng-app="login"&gt;
  
  &lt;head&gt;
  &lt;title&gt;Node Authentication&lt;/title&gt;
  &lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
  &lt;script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"&gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-animate.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-aria.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.4/angular-material.js"&gt;&lt;/script&gt;
  
  &lt;link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css"&gt;
  &lt;!-- load bootstrap css --&gt;
  &lt;link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css"&gt;
  &lt;!-- load fontawesome --&gt;
  &lt;script src="./javascripts/controllers/signup.js"&gt;&lt;/script&gt;
  &lt;style&gt;
      body {
          padding-top: 80px;
      }
  &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body ng-controller="loginCtrl"&gt;
  &lt;div class="container"&gt;
  
      &lt;div class="col-sm-6 col-sm-offset-3"&gt;
  
          &lt;h1&gt;&lt;span class="fa fa-sign-in"&gt;&lt;/span&gt; Signup&lt;/h1&gt;
  
          &lt;!-- show any messages that come back with authentication --&gt;
          &lt;% if (message.length&gt; 0) { %&gt;
              &lt;div class="alert alert-danger"&gt;
                  &lt;%=m essage %&gt;
              &lt;/div&gt;
              &lt;% } %&gt;
  
                  &lt;!-- LOGIN FORM --&gt;
                  &lt;form&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label&gt;Email&lt;/label&gt;
                          &lt;input type="text" class="form-control" ng-model="user.email"&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label&gt;Password&lt;/label&gt;
                          &lt;input type="password" class="form-control" ng-model="user.password"&gt;
                      &lt;/div&gt;
  
                      &lt;button ng-click="signup()" class="btn btn-warning btn-lg"&gt;Signup&lt;/button&gt;
                  &lt;/form&gt;
  
                  &lt;hr&gt;
  
                  &lt;p&gt;Already have an account? &lt;a href="/login"&gt;Login&lt;/a&gt;
                  &lt;/p&gt;
                  &lt;p&gt;Or go &lt;a href="/"&gt;home&lt;/a&gt;.&lt;/p&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p></p>
  
  <p><strong>Angular Controller Code:</strong></p>
  
  <pre><code>var login = angular.module('login', [])
  
  login.controller('loginCtrl', function($scope,$http){
  
  $scope.user = {};
  
  $scope.signup = function(){
  
     return $http.post('/signup',$scope.user)
     .then(function(data) {
     console.log("da" + data);
   });
   };
  
  })
  </code></pre>
  
  <p><strong>The Signup Route:</strong></p>
  
  <pre><code>    // process the signup form
  app.post('/signup', passport.authenticate('local-signup', {
      successRedirect : '/profile', // redirect to the secure profile section
      failureRedirect : '/signup', // redirect back to the signup page if there is an error
      failureFlash : true // allow flash messages
  }));
  </code></pre>
  
  <p><strong>Note:</strong></p>
  
  <p>In the backend I've setup a Node/Express.js API. On successful signup it uses passport.js to add the user into MongoDB and also redirects user to the profile page.</p>
  
  <p><strong>BUT</strong> currently the data is going into the database (<strong>I can see the new user in the db</strong>) its not redirecting the user to the profile page nor is it showing any error messages that I send back (i.e if a user already exists)</p>