Bird
0
0

You want to build a standalone button component reusable across multiple standalone components without NgModules. What is the correct approach?

hard📝 component behavior Q8 of 15
Angular - Standalone Components
You want to build a standalone button component reusable across multiple standalone components without NgModules. What is the correct approach?
ADeclare the button component inside a shared NgModule and import that module everywhere
BDeclare the button component with <code>standalone: true</code> and import it in each component that uses it
CUse <code>standalone: false</code> and declare the button in every component's declarations
DCreate the button component without <code>standalone</code> and use it directly without imports
Step-by-Step Solution
Solution:
  1. Step 1: Understand standalone component reuse

    Standalone components can be imported directly without NgModules.
  2. Step 2: Identify correct reuse method

    Import the standalone button component in each component that needs it.
  3. Step 3: Eliminate incorrect options

    Options B, C, and D rely on NgModules or incorrect declarations.
  4. Final Answer:

    Declare the button component with standalone: true and import it in each component that uses it -> Option B
  5. Quick Check:

    Import standalone components where needed [OK]
Quick Trick: Import standalone button component in each usage [OK]
Common Mistakes:
  • Using NgModules for standalone component reuse
  • Not importing standalone components before use
  • Declaring standalone components as non-standalone

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes