title: AngularJS - $http error callback not working even though error response returned from the Web API
body: <p>I am calling a method from the server which returns an error response like (400 &amp; 500 errors) but my AngularJS error callback is not getting called and always the success callback is getting called even though my status code contains 400's or 500's. Can someone please tell what am I doing wrong? Please see the angular &amp; WebAPI code below:</p>
  
  <p>AngularJS code:</p>
  
  <pre><code>$http.get("/api/employee")
      .success(function (data, status, headers, config) {
          console.log(data);
          return data;
      }).error(function (data, status, headers, config) {
          alert("error");
          return status;
  });
  </code></pre>
  
  <p>Web API code:</p>
  
  <pre><code>public HttpResponseMessage Get(EmployeeModel employee)
  {
       if (!ModelState.IsValid)
       {
           return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
       }
       //some other code
  }
  </code></pre>