Bird
0
0

Identify the error in this Angular standalone component declaration:

medium📝 Debug Q6 of 15
Angular - Standalone Components
Identify the error in this Angular standalone component declaration:

@Component({ selector: 'app-sample', template: '<p>Sample</p>' }) export class SampleComponent {}
ATemplate syntax is invalid.
BMissing selector property in @Component decorator.
CClass name must be SampleComponentComponent.
DMissing standalone: true property in @Component decorator.
Step-by-Step Solution
Solution:
  1. Step 1: Check standalone component requirements

    Standalone components must have standalone: true in their @Component decorator.
  2. Step 2: Verify given code

    The code lacks standalone: true, so it is treated as module-based, which is an error if standalone is intended.
  3. Final Answer:

    Missing standalone: true property in @Component decorator. -> Option D
  4. Quick Check:

    Standalone requires standalone: true in decorator = C [OK]
Quick Trick: Add standalone: true to declare standalone component [OK]
Common Mistakes:
  • Forgetting standalone: true in @Component
  • Confusing selector property as missing
  • Thinking class name must follow special pattern

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes