Invalid values make it in to the model
Closed this issue · 3 comments
When using validators such as minlength if the value is invalid then it doesn't make it in to the bound model.
For example:
<input type="password" id="inputPassword1" class="form-control" placeholder="Password" name='password1'
ng-model="user.password1" minlength="7">
<input type="password" id="inputPassword2" class="form-control" placeholder="Password" name='password2'
ng-model="user.password2" required data-match="user.password1" >
<pre>form = {{user | json}}</pre>
If password1 is less then 7 characters then the model won't contain a password1 field.
However with angular-input-match the password2 always reflects the value of the field even if it is invalid.
The match validation doesn't run in the $parsers
pipeline, which typically is what sets the $modelValue
to undefined
when its invalid. I can integrate this pipeline to allow this. The 1.3.x branch (which hasn't been touched in a while) uses the new $validators
pipeline and works are intended. If you are using angular 1.3.x, I would recommend that branch.
I'll fix the master branch to do this using the $parsers
when I get a sec, but please let me know what version of angular you are using.
@BrynCooke, try this now. The internal confirm value ($modelView
) will be undefined
when the fields do not match. The value shown in the input ($viewValue
) will not be changed.
http://jsfiddle.net/TheSharpieOne/vxkz1r2d/2/
Note: there is #5 which indicates that even if the first field is invalid, if the input value ($viewValue
) matches, it should be a valid match. Not too sure how that works with your case, or if it a wanted feature.
Hi sorry I didn't reply earlier. I can try early in the new year when I am
back at the desk. Thanks for looking at this.
On 23 Dec 2014 19:04, "Evan Sharp" notifications@github.com wrote:
@BrynCooke https://github.com/BrynCooke, try this now. The internal
confirm value ($modelView) will be undefined when the fields do not
match. The value shown in the input ($viewValue) will not be changed.http://jsfiddle.net/TheSharpieOne/vxkz1r2d/2/
Note: there is #5
#5 which
indicates that even if the first field is invalid, if the input value (
$viewValue) matches, it should be a valid match. Not too sure how that
works with your case, or if it a wanted feature.—
Reply to this email directly or view it on GitHub
#9 (comment)
.