Bird
0
0

What will happen if you try to access a control that does not exist in a FormGroup using get('unknown')?

medium🧠 Conceptual Q5 of 15
Angular - Reactive Forms
What will happen if you try to access a control that does not exist in a FormGroup using get('unknown')?
AReturns an empty FormControl
BReturns null
CReturns undefined
DThrows a runtime error
Step-by-Step Solution
Solution:
  1. Step 1: Recall FormGroup.get behavior

    FormGroup.get returns the control if found, otherwise returns null.
  2. Step 2: Check options for non-existing control

    Only returning null matches the documented behavior; no error or undefined is returned.
  3. Final Answer:

    Returns null -> Option B
  4. Quick Check:

    FormGroup.get unknown control = null [OK]
Quick Trick: get() returns null if control missing, not error [OK]
Common Mistakes:
MISTAKES
  • Expecting error thrown
  • Expecting undefined
  • Expecting empty control created

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes