title: angular $http.post then method doesn't work
body: <p>I use this function for loging in, but I face a problem in <code>$http.post</code> method. My sever response a 400 (bad request) to incorrect username &amp; password but in this angular code <code>loginSuccess</code> function run every time (even with incorrect username &amp; password) and other weird thing is that response is <code>undefined</code>, while I can see response in browser network console.</p>
  
  <pre><code>function login (data) {
        var deferred = $q.defer();
        $http.post('api/authentication/login', data)
          .then(loginSuccess, loginFailed);
  //        .success(loginSuccess);
  
        return deferred.promise;
  
        function loginSuccess (response) {
          console.log(response); // &lt;-- undefinde
          deferred.resolve();
        }
  
        function loginFailed () {
          deferred.reject();
        }
  
      }
  </code></pre>
  
  <p>But when I use <code>success</code> method (which is deprecated), there is no problem and login success doesn't run when response is error.</p>