title: Change AngularJS input[date] programmatically
body: <p>I'm trying to assing an <code>input[date]</code> control an initial value in the controller.</p>
  <p>From AngularJS <code>input[date]</code> documentation,</p>
  <blockquote>
  <p>The model must always be a Date object, otherwise Angular will throw
  an error.</p>
  </blockquote>
  <p>They provide a working example of how to init an <code>input[date]</code> in the controller (Pasted a <a href="http://plnkr.co/edit/4Rx7gteIrp6xFOLwqskx?p=preview" rel="nofollow noreferrer">simplified version</a>), that works on Plunker.</p>
  <pre><code>&lt;script&gt;
     angular.module('dateInputExample', [])
       .controller('DateController', ['$scope', function($scope) {
         $scope.value = new Date(2013, 9, 22);
       }]);
  &lt;/script&gt;
  &lt;form name=&quot;myForm&quot; ng-controller=&quot;DateController as dateCtrl&quot;&gt;
     &lt;input type=&quot;date&quot; id=&quot;exampleInput&quot; name=&quot;input&quot; ng-model=&quot;value&quot; /&gt;
  &lt;/form&gt;
  </code></pre>
  <p>When I do the same in my application I always get the following message:</p>
  <blockquote>
  <p>The specified value 'Sun Nov 09 2014 00:00:00 GMT+0100 (CET)' does not conform to the required format, 'yyyy-MM-dd'</p>
  </blockquote>
  <p>and the control is not initialized. Seems that it is expecting a string in ISO format and not a valid Date Object.</p>
  <p>In <a href="https://stackoverflow.com/questions/20261574/set-default-value-of-html5-date-input-field-with-angularjs">Set default value of HTML5 date input field with angularJS</a> an alternate method is proposed:</p>
  <pre><code>&lt;input type=&quot;date&quot; ng-model=&quot;date&quot; value=&quot;{{date}}&quot;&gt;
  ...
  $scope.date = $filter(&quot;date&quot;)(Date.now(), 'yyyy-MM-dd');
  </code></pre>
  <p>It just assigns a &quot;yyy-MM-dd&quot; string to the model. According to the docs this should throw an error, since a string is not a valid Date Object, but this second method works for me, but funny, does not work if you use it in the modified original <a href="http://plnkr.co/edit/4Rx7gteIrp6xFOLwqskx?p=preview" rel="nofollow noreferrer">Plunker</a>, adapted to use this method.</p>
  <ol>
  <li>What can be messing my <code>input[dates]</code> so I can't set the value in
  the controller as expected?</li>
  <li>Why is the alternate method working for me
  (and others) but not working in the simple demo provided?</li>
  </ol>
  <p>Here are some excerpts from my code where the input[type] is created and where it is assigned the initial value:</p>
  <p>index.html</p>
  <pre><code>&lt;input type=&quot;date&quot; name=&quot;input&quot;, ng-model=&quot;value&quot; /&gt;
  </code></pre>
  <p>Controller</p>
  <pre><code>.controller(&quot;UploadsCtrl&quot;,[&quot;$scope&quot;,&quot;$filter&quot;, function($scope, $filter) {
      // $scope.value = new Date(2013, 22, 9); // Not working
      $scope.value = &quot;2015-10-10&quot;; // Working!!!!
      ...
  </code></pre>