I am new to angular and when trying out form validations I came across following scenario :
Setup : I have one "required" field in my form which is bound to an ng-model and have a default value in it, and a reset button. I'm printing its value in a para tag.
Questions
Now when I remove the value from the field, my para tag is getting updated to null (no value) even when this value is invalid. So my question here is, why is my model value updated even when the new value is invalid.
Also, when i click on reset, the field is reset but the form's valid state is still true and the model is not updated as well. Why is that ?
Here is the code : http://plnkr.co/edit/fqczGwbponOW0kgs23Jn?p=preview
<form name="testForm">
<label>Name:</label>
<input type="text" ng-init="yourName = 'Sam'" ng-model="yourName" placeholder="Enter a name here" required>
<input type="reset" />
<p>Is form valid : {{testForm.$valid}}</p>
</form>
<p>Hello {{yourName}}!</p>