Bird
0
0

Why does this Angular component fail to render the template?

medium📝 Debug Q7 of 15
Angular - Components
Why does this Angular component fail to render the template?
@Component({ templateUrl: 'app.component.html' }) export class AppComponent { }

Assuming the file exists in the same folder.
AMissing './' prefix in templateUrl path
BtemplateUrl must be an absolute URL
CComponent class must have a template property
DAngular does not support external templates
Step-by-Step Solution
Solution:
  1. Step 1: Check templateUrl path format

    Relative paths in templateUrl require './' prefix to locate files correctly.
  2. Step 2: Identify missing prefix issue

    Without './', Angular may fail to find the file, causing rendering failure.
  3. Final Answer:

    Missing './' prefix in templateUrl path -> Option A
  4. Quick Check:

    Relative paths need './' prefix [OK]
Quick Trick: Use './' for relative templateUrl paths [OK]
Common Mistakes:
  • Assuming absolute URL required
  • Thinking class needs template property
  • Believing Angular disallows external templates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes