Bird
0
0

How do you instantiate a FormControl with the initial value set to 'world'?

easy📝 Syntax Q3 of 15
Angular - Reactive Forms
How do you instantiate a FormControl with the initial value set to 'world'?
Anew FormControl().setValue('world')
Bnew FormControl({value: 'world'})
Cnew FormControl('world')
DFormControl('world')
Step-by-Step Solution
Solution:
  1. Step 1: Understand FormControl constructor

    The FormControl constructor accepts an initial value as its first argument.
  2. Step 2: Check each option

    new FormControl('world') correctly passes 'world' as the initial value. new FormControl({value: 'world'}) incorrectly uses an object instead of a direct value. new FormControl().setValue('world') tries to call setValue on the instance but does not instantiate properly. FormControl('world') is invalid syntax.
  3. Final Answer:

    new FormControl('world') -> Option C
  4. Quick Check:

    Constructor takes initial value directly [OK]
Quick Trick: Pass initial value directly to FormControl constructor [OK]
Common Mistakes:
MISTAKES
  • Passing an object instead of a value
  • Calling setValue without instantiation
  • Using incorrect syntax without 'new'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes