Bird
0
0

You want to create a form array of controls for multiple phone numbers using FormBuilder. Which is the correct way?

hard🚀 Application Q9 of 15
Angular - Reactive Forms
You want to create a form array of controls for multiple phone numbers using FormBuilder. Which is the correct way?
Athis.fb.array(['123', '456'])
Bthis.fb.array([this.fb.control('123'), this.fb.control('456')])
Cthis.fb.control(['123', '456'])
Dthis.fb.group(['123', '456'])
Step-by-Step Solution
Solution:
  1. Step 1: Understand FormArray creation

    Form arrays hold an array of controls, each created with fb.control().
  2. Step 2: Identify correct array syntax

    this.fb.array([this.fb.control('123'), this.fb.control('456')]) correctly creates a FormArray with two controls initialized with phone numbers.
  3. Final Answer:

    this.fb.array([this.fb.control('123'), this.fb.control('456')]) -> Option B
  4. Quick Check:

    FormArray needs array of controls, not plain values [OK]
Quick Trick: Wrap each item in fb.control() inside fb.array() [OK]
Common Mistakes:
MISTAKES
  • Passing plain strings to array()
  • Using group() instead of array()
  • Using control() for multiple controls

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes