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<code>@Component({ standalone: false, selector: 'app-hello', template: '<p>Hello</p>' })</code>
B<code>@Component({ module: true, selector: 'app-hello', template: '<p>Hello</p>' })</code>
C<code>@NgModule({ standalone: true, declarations: [HelloComponent] })</code>
D<code>@Component({ standalone: true, selector: 'app-hello', template: '<p>Hello</p>' })</code>
Step-by-Step Solution
Solution:
  1. Step 1: Identify standalone component syntax

    The correct property is standalone: true inside the @Component decorator.
  2. Step 2: Check other options

    The other options are incorrect: one sets standalone: false, another uses invalid module property, and one misuses @NgModule.
  3. Final Answer:

    @Component({ standalone: true, selector: 'app-hello', template: '<p>Hello</p>' }) -> Option D
  4. Quick Check:

    standalone: true inside @Component decorator [OK]
Quick Trick: Look for standalone: true inside @Component decorator [OK]
Common Mistakes:
  • Using @NgModule instead of @Component for standalone
  • Setting standalone to false or missing it
  • Confusing module property with standalone

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes