Bird
0
0

Which of the following is the correct way to declare a standalone component in Angular?

easy📝 Syntax Q12 of 15
Angular - Standalone Components
Which of the following is the correct way to declare a standalone component in Angular?
A@NgModule({ standalone: true }) export class ExampleComponent {}
B@Component({ selector: 'app-example', module: true }) export class ExampleComponent {}
C@Component({ selector: 'app-example', standalone: true }) export class ExampleComponent {}
D@Component({ selector: 'app-example' }) export class ExampleComponent {}
Step-by-Step Solution
Solution:
  1. Step 1: Recall the syntax for standalone components

    Standalone components use standalone: true inside the @Component decorator.
  2. Step 2: Check each option's syntax

    @Component({ selector: 'app-example', standalone: true }) export class ExampleComponent {} correctly uses @Component with standalone: true. Others misuse decorators or omit the flag.
  3. Final Answer:

    @Component({ selector: 'app-example', standalone: true }) export class ExampleComponent {} -> Option C
  4. Quick Check:

    Standalone flag inside @Component = correct syntax [OK]
Quick Trick: Look for standalone: true inside @Component decorator [OK]
Common Mistakes:
  • Using @NgModule instead of @Component
  • Writing 'module: true' instead of 'standalone: true'
  • Omitting the standalone flag

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes