Bird
0
0

How can you use a standalone component inside a traditional NgModule-based Angular application?

hard📝 Application Q9 of 15
Angular - Standalone Components
How can you use a standalone component inside a traditional NgModule-based Angular application?
AImport the standalone component class in the NgModule's imports array.
BDeclare the standalone component in the NgModule's declarations array.
CAdd the standalone component selector directly in the NgModule bootstrap array.
DStandalone components cannot be used inside NgModules.
Step-by-Step Solution
Solution:
  1. Step 1: Understand integration of standalone components with NgModules

    Standalone components can be imported in the imports array of an NgModule to be used inside it.
  2. Step 2: Analyze options

    Import the standalone component class in the NgModule's imports array. correctly describes this. Declare the standalone component in the NgModule's declarations array. is invalid because standalone components are not declared. Add the standalone component selector directly in the NgModule bootstrap array. is unrelated. Standalone components cannot be used inside NgModules. is false.
  3. Final Answer:

    Import standalone component in NgModule imports array -> Option A
  4. Quick Check:

    Use standalone in NgModule imports = Import the standalone component class in the NgModule's imports array. [OK]
Quick Trick: Import standalone components in NgModule imports, not declarations [OK]
Common Mistakes:
  • Trying to declare standalone components in declarations
  • Assuming standalone components can't be used in NgModules
  • Misusing bootstrap array

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes