Bird
0
0

Identify the error in this Angular module code:

medium📝 Debug Q6 of 15
Angular - Modules
Identify the error in this Angular module code:
@NgModule({
  declarations: [MyComponent],
  imports: [CommonModule],
  exports: [CommonModule]
})
export class MyModule {}
ACommonModule should not be in exports; only declared components should be exported.
BThere is no error; this code is correct.
CCommonModule must be declared, not imported.
DMyComponent should be in imports, not declarations.
Step-by-Step Solution
Solution:
  1. Step 1: Understand what can be exported

    Exports can include declared components, directives, pipes, or imported modules to re-export them.
  2. Step 2: Analyze the code

    MyComponent is declared (valid), CommonModule is imported and exported (valid re-export).
  3. Final Answer:

    There is no error; this code is correct. -> Option B
  4. Quick Check:

    Exporting imported modules is allowed [OK]
Quick Trick: Exporting imported modules re-exports them [OK]
Common Mistakes:
  • Thinking imported modules cannot be exported
  • Putting components in imports
  • Confusing declarations and imports

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes