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:
Step 1: Understand form.reset() behavior
Calling reset() resets the form's value and clears dirty, touched, and other states to initial.
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.
Final Answer:
form.reset() -> Option C
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
Master "Reactive Forms" in Angular
9 interactive learning modes - each teaches the same concept differently