Angular 5
What is the difference between importing a module in app.module and importing it in the component that it is to be used in?
More specifically, why should a module have to be a part of node modules, app.module, the import array in app.module and the component, before it can be used?
An Angular module is there to centralize your imports and dependencies.
Imagine you have 170 components, that all need ToasterComponent.
What seems to be the best suited : write 170 imports to the same component, or one line of import ?
So sure, you can use it directly in the component, but if the dependency is shared and used at other places, consider using a module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With