Viv
Viv

Reputation: 963

Import a module in root module or root component

I have a third party library to control the layout of an angular app. I figured it should be imported somewhere that can be accessed through the whole app.
Is there any difference that I import it in app.module.ts (the root module), or import it in app.component.ts (the root component) ?

Upvotes: 0

Views: 1708

Answers (1)

MichaelSolati
MichaelSolati

Reputation: 2872

Modules, components, and services should always be imported through another Module. Making the declaration inside of the module not only allows for better modularity, but allows components to see other components, as well as allows for singleton services (may term may be incorrect, but the jist isn't).

If you have more questions about modules, please read this. I will say that everything depends on the library you are using, so if you let me know I can go into more detail.

Upvotes: 1

Related Questions