InterviewHubPRO
Section Overview
Q230

Question 230 of 283

Part 9: NgModules, Providers, NgZone & Injector Hierarchies (213 - 255)

81%
Angular & Signals (283 Qs)•Part 9: NgModules, Providers, NgZone & Injector Hierarchies (213 - 255)

What happens if browserModule used in feature module?

If you do import BrowserModule into a lazy loaded feature module, Angular returns an error telling you to use CommonModule instead. Because BrowserModule’s providers are for the entire app so it should only be in the root module, not in feature module. Whereas Feature modules only need the common directives in CommonModule.

ScreenShot

Practical Code Example

text
// BrowserModule in Feature Module:
// Throws: "BrowserModule has already been loaded. If you need CommonModule, import it instead."
// BrowserModule must ONLY be imported once in the root AppModule!