Bird
0
0

You want to create a shared Angular module that provides a component and re-exports CommonModule and FormsModule for use in other modules. Which is the correct way to set up the module?

hard📝 Application Q8 of 15
Angular - Modules
You want to create a shared Angular module that provides a component and re-exports CommonModule and FormsModule for use in other modules. Which is the correct way to set up the module?
A@NgModule({ declarations: [SharedComponent], imports: [CommonModule, FormsModule], exports: [SharedComponent, CommonModule, FormsModule] })
B@NgModule({ declarations: [SharedComponent], imports: [], exports: [SharedComponent, CommonModule, FormsModule] })
C@NgModule({ declarations: [SharedComponent], imports: [CommonModule, FormsModule], exports: [SharedComponent] })
D@NgModule({ declarations: [], imports: [CommonModule, FormsModule], exports: [SharedComponent, CommonModule, FormsModule] })
Step-by-Step Solution
Solution:
  1. Step 1: Include SharedComponent in declarations

    Components must be declared in the module to be used or exported.
  2. Step 2: Import CommonModule and FormsModule

    To use these modules internally and re-export them, they must be in imports.
  3. Step 3: Export SharedComponent and the imported modules

    To share the component and modules with other modules, list them in exports.
  4. Final Answer:

    Declarations include SharedComponent; imports and exports include CommonModule and FormsModule. -> Option A
  5. Quick Check:

    Declare components, import and export modules to share [OK]
Quick Trick: Declare components; import and export modules to share [OK]
Common Mistakes:
  • Not declaring components before exporting
  • Exporting modules without importing
  • Leaving declarations empty when exporting components

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes