Bird
0
0

Identify the error in this template snippet:

medium📝 Debug Q6 of 15
Angular - Component Interaction
Identify the error in this template snippet:
<input #input1 type="text">
<button (click)="submit(input2.value)">Submit</button>
AThe button click syntax is incorrect
Binput2 is not defined as a template reference variable
Cinput1 should be used instead of input2
DThere is no error
Step-by-Step Solution
Solution:
  1. Step 1: Check declared template references

    The template only declares #input1, but the button uses input2 which is not declared.
  2. Step 2: Understand consequences

    Using an undeclared template reference variable causes a template error because input2 is undefined.
  3. Final Answer:

    input2 is not defined as a template reference variable -> Option B
  4. Quick Check:

    Use only declared template refs [OK]
Quick Trick: Use only declared template refs in template expressions [OK]
Common Mistakes:
  • Assuming any variable name works
  • Ignoring undeclared references

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes