Bird
0
0

In a reactive form, you want to reset the form and clear all states including dirty and touched. Which method should you use?

hard🚀 Application Q9 of 15
Angular - Reactive Forms
In a reactive form, you want to reset the form and clear all states including dirty and touched. Which method should you use?
Aform.markAsPristine()
Bform.markAsUntouched()
Cform.reset()
Dform.updateValueAndValidity()
Step-by-Step Solution
Solution:
  1. Step 1: Understand form.reset() behavior

    Calling reset() resets the form's value and clears dirty, touched, and other states to initial.
  2. Step 2: Compare with other methods

    markAsPristine() and markAsUntouched() only change specific states but do not reset values. updateValueAndValidity() triggers validation but does not reset states.
  3. Final Answer:

    form.reset() -> Option C
  4. Quick Check:

    reset() clears values and all states [OK]
Quick Trick: Use reset() to clear form values and states [OK]
Common Mistakes:
MISTAKES
  • Using markAsPristine() alone to reset form
  • Confusing updateValueAndValidity() with reset
  • Expecting markAsUntouched() to reset values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes