Bird
0
0

Given this code snippet, what will be the initial value of the form control named email?

medium📝 component behavior Q13 of 15
Angular - Reactive Forms
Given this code snippet, what will be the initial value of the form control named email?
this.form = this.fb.group({
  email: ['user@example.com'],
  password: ['']
});
A'user@example.com'
Bundefined
Cnull
DAn empty string
Step-by-Step Solution
Solution:
  1. Step 1: Understand FormBuilder group initialization

    The email control is initialized with the array containing the string 'user@example.com'.
  2. Step 2: Identify initial value of the control

    The first element in the array is the initial value, so the email control starts with 'user@example.com'.
  3. Final Answer:

    'user@example.com' -> Option A
  4. Quick Check:

    Initial control value = first array element [OK]
Quick Trick: First array item is initial form control value [OK]
Common Mistakes:
MISTAKES
  • Assuming empty string as default
  • Confusing null or undefined as initial value
  • Ignoring array syntax for initial value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes