title: How to handle date fields from a REST Api in AngularJS?
body: <p>I've got a REST API that returns JSON data with dates in a standard ISO-8601 format: yyyy-MM-ddTHH:mm:ss:</p>
  
  <pre><code>{
      id: 4
      version: 3
      code: "ADSFASDF"
      definition: "asdflkj"
      type: "CONTAINER"
      value: "1234"
      active: "false"
      formula: false
      validTo: "2014-12-31T05:00:00"
      validFrom: "2010-12-31T10:00:00"
  }
  </code></pre>
  
  <p>My issue is that I'm not quite sure how to deal with this in AngularJS.  I have a <code>$resource</code> which GETs, POSTs, etc my API endpoints, but when my data is returned, it is stored in my JS object as as String.  I figure that it would be easier to handle as a Date() or a Moment().</p>
  
  <p>In Java, I can use a <code>JsonDeserializer</code> to ensure that all JSON data is properly converted prior to being assigned to the model, but I don't know if there is a similar mechanism in AngularJS.</p>
  
  <p>I've searched around, but can't seem to find anything that implements a generalized solution.  I realize that I can use a <code>transformResponse</code> function in my <code>$resource</code>, but that seems like a lot of repeated configuration for every data type that may contain a date.</p>
  
  <p>This leads me to wonder if returning the date in an ISO-8601 format is the best way to proceed?  If AngularJS doesn't support it out of the box, I presume that there must be an easier way to deal with dates.  How does one deal with dates in AngularJS?  Should I just be treating them as text/string objects, and have the API return a pre-formatted version?  If so, what is the most flexible format to use in an HTML5 date input box, etc?</p>