Bird
0
0

Find the issue in this reactive form setup:

medium📝 Debug Q7 of 15
Angular - Reactive Forms
Find the issue in this reactive form setup:
this.form = new FormGroup({
  password: new FormControl('')
});
this.form.value.password = '12345';
ADirectly assigning to form.value properties does not update the form control
BFormControl cannot be initialized with empty string
CFormGroup must be declared as a constant
Dpassword control should be a FormGroup, not FormControl
Step-by-Step Solution
Solution:
  1. Step 1: Understand form.value immutability

    form.value is a snapshot object and cannot be mutated directly to update controls.
  2. Step 2: Correct way to update control value

    Use form.controls['password'].setValue('12345') to update the control.
  3. Final Answer:

    Directly assigning to form.value properties does not update the form control -> Option A
  4. Quick Check:

    Update controls via setValue, not form.value object [OK]
Quick Trick: Use setValue() to update form controls, not form.value directly [OK]
Common Mistakes:
MISTAKES
  • Trying to mutate form.value directly
  • Confusing FormControl initialization rules
  • Misusing FormGroup and FormControl types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes