Bird
0
0

You want to show validation errors only after the user tries to submit the form, not on every field touch. Which Angular approach best supports this behavior?

hard🧠 Conceptual Q9 of 15
Angular - Template-Driven Forms
You want to show validation errors only after the user tries to submit the form, not on every field touch. Which Angular approach best supports this behavior?
AShow errors whenever control.invalid is true regardless of user action
BUse control.disabled to hide errors before submit
CUse control.pristine to decide when to show errors
DUse a submitted flag in the component and show errors if submitted is true and control is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Understand requirement to delay error display until submit

    Errors should not show on touch but only after submit attempt.
  2. Step 2: Use a submitted flag to track form submission

    Set a boolean submitted = true on submit, then show errors if submitted is true and control is invalid.
  3. Final Answer:

    Use a submitted flag in the component and show errors if submitted is true and control is invalid -> Option D
  4. Quick Check:

    Use submitted flag to control error display timing [OK]
Quick Trick: Control error display timing with a submitted flag [OK]
Common Mistakes:
MISTAKES
  • Showing errors immediately on invalid state
  • Using pristine which resets on user input
  • Using disabled which hides control entirely

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes