Bird
0
0

Which of the following is the correct syntax to define a component with an external template file named app.component.html?

easy📝 Syntax Q3 of 15
Angular - Components
Which of the following is the correct syntax to define a component with an external template file named app.component.html?
A@Component({ templateUrl: 'app.component.html' })
B@Component({ templateUrl: './app.component.html' })
C@Component({ template: 'app.component.html' })
D@Component({ templateFile: 'app.component.html' })
Step-by-Step Solution
Solution:
  1. Step 1: Understand templateUrl usage

    The templateUrl property points to the external HTML file, usually with a relative path starting with './'.
  2. Step 2: Identify correct syntax

    @Component({ templateUrl: './app.component.html' }) correctly uses templateUrl with a relative path string.
  3. Final Answer:

    @Component({ templateUrl: './app.component.html' }) -> Option B
  4. Quick Check:

    External template uses templateUrl with relative path [OK]
Quick Trick: Use templateUrl with relative path for external HTML [OK]
Common Mistakes:
  • Using 'template' instead of 'templateUrl' for files
  • Omitting './' in path causing file not found
  • Using invalid property 'templateFile'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes