Bird
0
0

What is wrong with this code?

medium📝 Debug Q7 of 15
Angular - Reactive Forms
What is wrong with this code?
const control = new FormControl('');
control.patchValue('new');
ApatchValue is not a method on FormControl
BNo error, code works fine
CpatchValue cannot update FormControl value
DpatchValue requires an object argument
Step-by-Step Solution
Solution:
  1. Step 1: Check patchValue on FormControl

    FormControl supports patchValue as an alias to setValue for single values.
  2. Step 2: Validate argument type

    Passing a string to patchValue on FormControl is valid.
  3. Final Answer:

    No error, code works fine -> Option B
  4. Quick Check:

    patchValue works on FormControl with single value [OK]
Quick Trick: patchValue works on FormControl like setValue [OK]
Common Mistakes:
MISTAKES
  • Thinking patchValue only works on FormGroup
  • Expecting patchValue needs object always
  • Confusing patchValue with setValue differences

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes