Bird
0
0

Identify the error in this Angular component code:

medium📝 Debug Q6 of 15
Angular - Components
Identify the error in this Angular component code:
@Component({ selector: 'app-test', template: '

{{title}}

' }) export class TestComponent { title; }
ASelector name is invalid
Btitle is declared but not initialized, causing undefined display
CMissing @Injectable decorator
DTemplate syntax is incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Check property initialization

    The title property is declared but not given a value, so it is undefined.
  2. Step 2: Understand template binding effect

    Binding to undefined shows empty or blank in the rendered template.
  3. Final Answer:

    title is declared but not initialized, causing undefined display -> Option B
  4. Quick Check:

    Uninitialized properties show undefined [OK]
Quick Trick: Initialize properties to avoid undefined in templates [OK]
Common Mistakes:
  • Thinking @Injectable is needed for components
  • Assuming selector is invalid without reason
  • Believing template syntax is wrong here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes