简体   繁体   中英

Angular date filter not working with two-way data binding

I have the following code:

<input type="date" name="dat" ng-model="dat" placeholder="date">
<h3>Date: {{dat | date:'fullDate'}}</h3>
{{1288323623006 | date:'fullDate'}}

The first interpolation shows nothing no matter what I type in the input element, but the second interpolation displays the date as it should. I'm using angular 1.4.5 and I don't have this problem when I use angular 1.2.x. I'm guessing I missed some update regarding the date filter, but I can't seem to find any mention of this on google.

I also don't have this problem (even with angular 1.4.5) when I change the type of input element to number.

I was a bit hasty to post my question. The thing that I didn't realize was that from version 1.3 the validator is no longer a part of the parser/formatter pipeline and since I'm entering numbers and not valid dates the model is never updated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM