Bird
0
0

This component code throws an error:

medium📝 Debug Q7 of 15
Angular - Components
This component code throws an error:
@Component({
  selector: 'app-error',
  template: `

Error

`, styles: '.error { color: red; }', encapsulation: ViewEncapsulation.Emulated }) export class ErrorComponent {}

What is the error?
AStyles should be an array, not a string
BThe selector is invalid
CTemplate syntax is incorrect
DViewEncapsulation.Emulated is deprecated
Step-by-Step Solution
Solution:
  1. Step 1: Check styles property type

    Styles must be an array of strings, not a single string.
  2. Step 2: Validate other properties

    Selector and template are valid; Emulated is not deprecated.
  3. Final Answer:

    Styles should be an array, not a string -> Option A
  4. Quick Check:

    Styles property requires array syntax [OK]
Quick Trick: Always wrap styles in an array, even if one string [OK]
Common Mistakes:
  • Passing styles as string
  • Misnaming selector
  • Incorrect template syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes