I have run across a weird/confusing behavior with <input>
and form validation.
Essentially, if input has an invalid numeric value (which sets form.$valid
to false
), if a model value is changed to null
, it sets the $valid
flag back to true
, but doesn't change the value displayed in the input field.
I have created a plunker to illustrate. Follow these steps to reproduce:
- Modify value of a cell to empty.
- Click on save link (which saves
null
into model) - Input a non-numeric character.
- Click on reset link (which restores
null
from model) - Observe that the input field is no longer invalid, but the invalid character is still there.
Is this a bug or am I doing something wrong?
EDIT:
I'm starting to believe that it is a bug. I "fixed" it by introducing another directive that forces ""
value for null
.
Here's a fork of the plunker above with the "fix".
EDIT2:
This was fixed in v1.3+