Bird
0
0

What is wrong with this Angular code snippet?

medium📝 Debug Q6 of 15
Angular - Reactive Forms
What is wrong with this Angular code snippet?
const fa = new FormArray();
fa.push('new control');
AYou must push a FormControl instance, not a string
BFormArray cannot be instantiated without initial controls
Cpush() method does not exist on FormArray
DYou need to call addControl() instead of push()
Step-by-Step Solution
Solution:
  1. Step 1: Check push() argument

    push() expects a FormControl, FormGroup, or FormArray instance.
  2. Step 2: Identify the error

    Passing a string directly causes a type error.
  3. Final Answer:

    You must push a FormControl instance, not a string -> Option A
  4. Quick Check:

    push() requires FormControl instance [OK]
Quick Trick: push() requires FormControl instance [OK]
Common Mistakes:
MISTAKES
  • Pushing primitive values instead of FormControl
  • Thinking push() doesn't exist
  • Confusing addControl() with push()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes