Bird
0
0

How can you share a directive declared in one Angular module with multiple other modules without redeclaring it?

hard📝 Application Q9 of 15
Angular - Modules
How can you share a directive declared in one Angular module with multiple other modules without redeclaring it?
AAdd the directive to the providers array of each module.
BDeclare the directive in each module that needs it.
CDeclare the directive in one module and export it; import that module in others.
DUse the directive without declaring or importing it.
Step-by-Step Solution
Solution:
  1. Step 1: Understand Angular's module sharing

    To share a directive, declare and export it in one module.
  2. Step 2: Import the module in other modules

    Other modules import the module that exports the directive to use it without redeclaring.
  3. Final Answer:

    Declare the directive in one module and export it; import that module in others. -> Option C
  4. Quick Check:

    Export once, import many [OK]
Quick Trick: Export directive once; import module everywhere [OK]
Common Mistakes:
  • Redeclaring directive in multiple modules
  • Adding directives to providers
  • Using directives without declaration or import

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes