Bird
0
0

Given this reactive form code snippet, what will be the output when console.log(this.form.value) is called after initialization?

medium📝 state output Q13 of 15
Angular - Reactive Forms
Given this reactive form code snippet, what will be the output when console.log(this.form.value) is called after initialization?
this.form = new FormGroup({
  email: new FormControl(''),
  password: new FormControl('1234')
});
A{ email: '', password: '1234' }
B{ email: null, password: null }
C{ email: undefined, password: '1234' }
DError: form not initialized
Step-by-Step Solution
Solution:
  1. Step 1: Check initial values of form controls

    The email control is initialized with an empty string '', and password with '1234'.
  2. Step 2: Understand form.value output

    Calling form.value returns an object with current values of each control.
  3. Final Answer:

    { email: '', password: '1234' } -> Option A
  4. Quick Check:

    form.value = current control values [OK]
Quick Trick: form.value shows current control values as object [OK]
Common Mistakes:
MISTAKES
  • Assuming uninitialized controls are null or undefined
  • Expecting error without initialization
  • Confusing form.value with form.controls

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes