Skip to main content

What is the role of the CoreModule and why must it be loaded once?

Expert Angular
Quick Answer CoreModule holds app-wide singleton services (AuthService, LoggingService, HTTP interceptors) and is imported only once in AppModule. Importing it in feature modules would create duplicate service instances. Guard against multiple imports: add a constructor check that throws if the module was already loaded. Angular's providedIn: "root" mostly replaces CoreModule for services in modern Angular.

Answer

CoreModule contains global singletons (services, interceptors, configs). Loading it more than once creates duplicate instances and breaks global state.

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