Skip to main content

Why is SharedModule used and what should it contain?

Expert Angular
Quick Answer SharedModule contains: commonly used components (buttons, cards, inputs), directives, pipes, and Angular modules re-exported for convenience (CommonModule, ReactiveFormsModule). Import it in any feature module that needs shared UI. SharedModule should NOT provide services (would create duplicates). Keep it lean - only add what's used in 3+ feature modules.

Answer

SharedModule contains reusable UI pieces—components, directives, pipes. It must NOT contain stateful services to avoid duplicated instances.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice