title: Angular JS with MVC4 model binding failing with date/datetime?
body: <p>When using Angular JS to post back to the server with a complex object the datetime and datetime? values do not bind correctly. I have tried JSON.stringify to no avail. I have posted a related question though possibly it was too general. What I really need to know is how to correctly pass those dates in. What I am currently doing is using  workaround in js to convert the dates but I would rather not do that and simply get the dates in the form I need them when in Angular and then pass back the correct values.</p>
  
  <p>How do you bind to those datetime/datetime? values correctly? Please see the following code example and Fiddler post results.</p>
  
  <p>C# Class:</p>
  
  <pre><code>public class Person
  {
      public string FirstName { get; set; }
      public string LastName { get; set; }
      public DateTime BirthDate { get; set; }
      public DateTime? ApprovedForSomething { get; set; }
  }
  </code></pre>
  
  <p>Angular JS Controller: </p>
  
  <pre><code>function PersonController($scope, $http) {
      $scope.getPerson = function () {
          $http.get('../../Home/GetPerson/1').success(function (data) {
              $scope.Person = data;
          });
      }
      $scope.updateApprovedForSomething = function () {
          $http.post('../../Home/UpdatePerson', { person: $scope.Person }).success(function (data) {
              console.log(data);
          });
      }
  }
  </code></pre>
  
  <p>Fiddler Post:</p>
  
  <blockquote>
    <p>HTTP/1.1 200 OK Cache-Control: private Content-Type: application/json;
    charset=utf-8 Server: Microsoft-IIS/8.0 X-AspNetMvc-Version: 4.0
    X-AspNet-Version: 4.0.30319 X-SourceFiles:
    =?UTF-8?B?YzpcdXNlcnNcbmlja1xkb2N1bWVudHNcdmlzdWFsIHN0dWRpbyAyMDEyXFByb2plY3RzXFZhbGlkYXRpb25UZXN0XEhvbWVcR2V0UGVyc29uXDE=?=
    X-Powered-By: ASP.NET Date: Wed, 16 Jan 2013 14:48:34 GMT
    Content-Length: 124</p>
    
    <p>{"FirstName":"Bob","LastName":"Smith","BirthDate":"/Date(695573315098)/","ApprovedForSomething":"/Date(1358261315098)/"}</p>
  </blockquote>
  
  <p>This is the result on the server side. The datetime binds to a new datetime value which is not correct and the datetime? is null. </p>
  
  <p><img src="https://i.stack.imgur.com/9Ewxo.png" alt="enter image description here"></p>