Bird
0
0

Given this test code snippet, what will be the value of component.form.controls['email'].valid after setting component.form.controls['email'].setValue('test@example.com') if the email control has a required and email validator?

medium📝 state output Q4 of 15
Angular - Testing
Given this test code snippet, what will be the value of component.form.controls['email'].valid after setting component.form.controls['email'].setValue('test@example.com') if the email control has a required and email validator?
Anull
Bfalse
Cundefined
Dtrue
Step-by-Step Solution
Solution:
  1. Step 1: Understand validators on email control

    The email control requires a non-empty value and a valid email format.
  2. Step 2: Check the value set

    'test@example.com' is a valid email and not empty, so both validators pass.
  3. Final Answer:

    true -> Option D
  4. Quick Check:

    Valid email value = valid control true [OK]
Quick Trick: Valid email string passes required and email validators [OK]
Common Mistakes:
  • Assuming valid property is false for valid input
  • Confusing valid with touched or dirty
  • Expecting null or undefined instead of boolean

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes