0

For the following code:

userType: <input name="input" ng-model="userType" required> 
...
myForm.input.$valid = {{myForm.input.$valid}}
myForm.input.$error = {{myForm.input.$error}}

Both $valid and $error will be false if the user touched the input and left it empty.

My question is:

  1. How does angularjs define $valid and $error? For example, $touched has two states (touched or untouched). but what does it mean by "valid" or "invalid"?
  2. Can I customize or redefine them?

1 Answer 1

2

$valid simply return a boolean value depending on input is valid or not. But $error provide detail information about the errors. For eg, if you couple of validations setup for a form and all of them are invalid, then the error will show the details description of all the errors.

Demo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.