Bird
0
0

You want to create a reusable button component as standalone and use it in multiple other standalone components without NgModules. Which approach is correct?

hard📝 Application Q15 of 15
Angular - Standalone Components
You want to create a reusable button component as standalone and use it in multiple other standalone components without NgModules. Which approach is correct?
ACreate the button without standalone and declare it in a shared NgModule imported everywhere.
BCreate the button as a directive and add it to the root NgModule.
CCreate the button as a service and inject it into components.
DCreate the button with <code>standalone: true</code> and import it in each component's <code>imports</code> array where used.
Step-by-Step Solution
Solution:
  1. Step 1: Understand standalone component reuse

    Standalone components can be reused by importing them directly in other standalone components.
  2. Step 2: Identify the correct reuse method without NgModules

    Create the button with standalone: true and import it in each component's imports array where used. uses standalone: true and imports the button in each component, avoiding NgModules.
  3. Final Answer:

    Create the button with standalone: true and import it in each component's imports array where used. -> Option D
  4. Quick Check:

    Standalone reuse = import in each component [OK]
Quick Trick: Import standalone components where needed; no NgModules required [OK]
Common Mistakes:
  • Trying to use NgModules with standalone components
  • Confusing services with UI components
  • Using directives instead of components for buttons

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes