But the message never shows even after typing a valid email. What is the likely problem?
medium
A. The form control is not marked as touched, so the message won't show.
B. The valid property is misspelled and should be isValid.
C. The form control might have an email validator, so valid is false.
D. The dirty property does not update on user input.
Solution
Step 1: Understand the condition for showing the message
The message shows only if the control is both dirty and valid.
Step 2: Check if validation is set up
If the form control has an email validator but the input doesn't pass it (even if it looks valid), valid is false, so the message won't appear.
Final Answer:
The form control might have an email validator, so valid is false. -> Option C
Quick Check:
Missing validator means valid stays false [OK]
Hint: Check validators if valid never becomes true [OK]
Common Mistakes:
Thinking touched affects this condition
Using wrong property names like isValid
Assuming dirty never updates on input
5. You want to disable the submit button in an Angular reactive form until the user has changed at least one input and all inputs are valid. Which condition correctly implements this logic in the template?
<button [disabled]="???">Submit</button>
hard
A. [disabled]="form.pristine || form.invalid"
B. [disabled]="!form.touched || !form.valid"
C. [disabled]="form.touched && form.valid"
D. [disabled]="!form.dirty && !form.valid"
Solution
Step 1: Understand form state properties
pristine means no changes made, opposite of dirty. invalid means form is not valid.
Step 2: Translate requirement to condition
Disable button if form is pristine (no changes) or invalid (not valid). So disable when form.pristine || form.invalid.
Final Answer:
[disabled]="form.pristine || form.invalid" -> Option A
Quick Check:
Disable if no changes or invalid [OK]
Hint: Disable if pristine or invalid to require change and validity [OK]
Common Mistakes:
Using dirty instead of pristine incorrectly
Confusing valid with invalid
Using touched instead of dirty/pristine
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.