title: Convert C# DateTime To Angular Date
body: <p>I have an Angular collection bound to a repeater that is populated from an MVC JsonResult. </p>
  
  <pre><code>    $scope.loadData = function () {
          $http.get('/Product/GetDiscountCodes')
            .then(function (result) {
                console.log(result);
                $scope.discountCodes = result.data.DiscountCodes;
                $scope.selected = {};
            });
      };
  </code></pre>
  
  <p>One of the fields in the repeater is populated with the date. The date returned from the server is C# DateTime which looks like this:</p>
  
  <p>1/5/2015 12:02:00 AM</p>
  
  <p>However when it is bound by Angular is displays like this:</p>
  
  <p>/Date(1420434120000)/</p>
  
  <p>How can I get the date to display properly in my textfield in mm/dd/yyyy format?</p>
  
  <p>I tried the ui-utils date format but that didn't work.</p>
  
  <p>I also tried creating my own directive which formats the date properly but when the save event happens, the date send to the server side method is all jacked up.</p>
  
  <pre><code>       function inputDate() {
      return {
          require: 'ngModel',
          link: function (scope, element, attrs, ngModelController) {
              ngModelController.$parsers.push(function (data) {
                  if (data === null) { return null; }
                  var d = moment(data).format('YYYY-MM-DD');
                  return d;
              });
  
              ngModelController.$formatters.push(function (data) {
                  if (data === null) { return null; }
                  return moment(data).format('MM/DD/YYYY');
              });
          }
      }
  }
     angular.module('discountApp')
      .directive('inputDate', inputDate);
  </code></pre>
  
  <p>THanks for the help!</p>