I have an input defined as
<input class="datepicker" type="text" ng-model="clientForm.birthDate" />
Which is rigged up to be displayed elsewhere on the page:
<tr>
<th>Birth Date</th>
<td>{{client.birthDate|date:'mediumDate'}}</td>
</tr>
When the page loads the birth date is nicely formatted as something like Dec 22, 2009
. However, when I look inside my <input>
it's shown as Tue Dec 22 2009 00:00:00 GMT-0800 (Pacific Standard Time)
which I guess is how JS renders Date
objects as strings.
Firstly, how do I tell Angular to show the date in the <input>
as something like 12/22/2009
? I can't seem to apply |filters
inside the ng-model
attribute.
Secondly, as soon as I edit the date, even keeping it in it's original format, my other text (inside the <td>
) doesn't seem to apply the |date
filter anymore; it suddenly changes formats to match that of the input textbox. How do I get it to apply the |date
filter every time the model changes?
Related questions:
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…