Bird
0
0

Identify the error in this template snippet:

medium📝 Debug Q6 of 15
Angular - Template-Driven Forms
Identify the error in this template snippet:
<input ngModel="userName">
AProperty name should be in single quotes
BMissing square brackets for binding: should be [(ngModel)]
CngModel directive cannot be used on input elements
DngModel requires a form tag parent
Step-by-Step Solution
Solution:
  1. Step 1: Check ngModel binding syntax

    For two-way binding, [(ngModel)] is required, not just ngModel="...".
  2. Step 2: Validate other options

    ngModel works on inputs, property names don't need quotes, and form tag is optional.
  3. Final Answer:

    Missing square brackets for binding: should be [(ngModel)] -> Option B
  4. Quick Check:

    Two-way binding needs [(ngModel)] [OK]
Quick Trick: Use [(ngModel)] for binding, not ngModel="" alone [OK]
Common Mistakes:
MISTAKES
  • Using ngModel without brackets
  • Thinking ngModel needs form tag
  • Adding quotes around property name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes