0
I have the following HTML code with Angularjs:
<html ng-app>
//...
<form name="myForm2">
<input type="email" id="email" name="email" ng-model="formData.email" required/>
<span ng-show="!myForm2.email.$error.required && myForm2.email.$error.email && myForm2.email.$dirty">invalid email {{formData.email}}</span>
</form>
//...
</html>
What I want is, if the user enters the wrong email field, the message "invalid email value_completed_no_field".
It turns out that the above code only returns the message "invalid email", I am not able to capture the field value.
What’s wrong with the code above?
I’m not sure, but I believe he’s setting the
formData.email
fornull
because the value ofinput
is invalid. I will try to find something in the documentation that proves this, then put an answer.– gabrielhof
@gabrielhof I think you’re right, I ran a test and put the correct e-mail and {{formData.email}} out of span (because it is hidden) and already appears. However I noticed that if you put "email@dominio" he considers it right and as we can see, it is not.
– Filipe Moraes