Bird
0
0

What is the expected behavior if you use [(ngModel)] in your template but forget to import FormsModule in your Angular module?

medium📝 component behavior Q5 of 15
Angular - Template-Driven Forms
What is the expected behavior if you use [(ngModel)] in your template but forget to import FormsModule in your Angular module?
AAngular throws a template parse error indicating <code>ngModel</code> is unknown.
BThe two-way binding works but with warnings in the console.
CThe input field will be disabled automatically.
DThe component property will not update but no error is shown.
Step-by-Step Solution
Solution:
  1. Step 1: Understand module imports

    FormsModule must be imported to use ngModel directive.
  2. Step 2: Consequence of missing import

    Without importing FormsModule, Angular does not recognize ngModel and throws a template parse error.
  3. Final Answer:

    Angular throws a template parse error indicating ngModel is unknown. -> Option A
  4. Quick Check:

    Missing FormsModule causes parse errors for ngModel. [OK]
Quick Trick: Always import FormsModule to use ngModel. [OK]
Common Mistakes:
MISTAKES
  • Assuming ngModel works without FormsModule
  • Ignoring template parse errors
  • Expecting silent failures

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes