chbachman chbachman - 5 months ago 21
Javascript Question

Angular Date Filter not filtering in ng-value

// date = 2015-12-05T02:34:45.249Z
<div>
<p>{{date | date:'yyyy/MM/dd'}}</p> // This works, shows the correct date
</div>

<label>
<input type="date" ng-value="{{date | date:'yyyy/MM/dd'}}"> // This doesn't work
</label>


Codepen

I'm not sure what is going on. The first filter works well, but the second one doesn't format the date at all, leaving the date as the initial string.

Answer Source

Try:

<label>
    <input type="date" ng-value="date | date:'yyyy/MM/dd'">
</label>

This will show the correct date format in your structure