Bird
0
0

Identify the error in this standalone component declaration:

medium📝 Debug Q6 of 15
Angular - Standalone Components
Identify the error in this standalone component declaration:
@Component({
  selector: 'app-sample',
  standalone: true,
  templateUrl: './sample.component.html'
})
export class SampleComponent {}
AMissing imports array for used standalone components.
BNo error; this is a valid standalone component declaration.
CtemplateUrl cannot be used in standalone components.
Dstandalone must be set to 'true' as a string.
Step-by-Step Solution
Solution:
  1. Step 1: Check templateUrl usage

    Standalone components can use templateUrl to load external templates.
  2. Step 2: Verify standalone property type

    standalone must be boolean true, which it is here.
  3. Final Answer:

    No error; this is a valid standalone component declaration. -> Option B
  4. Quick Check:

    Valid standalone syntax = No error; this is a valid standalone component declaration. [OK]
Quick Trick: templateUrl works fine in standalone components [OK]
Common Mistakes:
  • Thinking templateUrl is disallowed
  • Using string 'true' instead of boolean true
  • Assuming imports array is mandatory if no other components used

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes