What do touched, dirty and pristine mean?
Model answer
touched means the user has focused and left the control (blur). untouched is the opposite. dirty means the value has been changed by the user, and pristine means it has not.
Use them to decide when to show errors: showing "required" on a field before the user has touched it is annoying. A common rule is to show errors when the control is invalid and (touched or the form was submitted).
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.
More questions
- What is the difference between template-driven and reactive forms?
- How do you add validation to a reactive form?
- How do you write a custom validator?
- What are async validators and when do you need one?
- What are FormArray and dynamic forms?
- What is the difference between valueChanges and statusChanges, and how do you use them safely?