It is totally possible to create an Angular application, even a "large appliation", by only using one module. So why do we even have named modules in the first place, and when do you really need to use different modules?
Well, I was recently watching a Pluralsight course (honestly, I forget exactly which one) and the author that something that really seemed to make sense to me; you use a new module for code that is shared across projects. A module works by injecting it when your application's module if first created. If have widgets or reusable components that you think may be able to be reused in another project then you will definitely want to put those things in their own module (how else could you put it in two diferent modules without copy-pasting code?.
Although keeping your code modular and encapsulated is super important, it can be possible to go too far when working with modules. I'll usually make one "Jim Components Module" to contain different Angular 1 objects that I think might be reusable. Honestly, I when I'm doing heavy typing coding new features on an app I'll usually just throw everything into the same module. During that time I'm probably more concerned with other things, and that's the sort of thing that you can always just refactor later.
The posts on this site are written and maintained by Jim Lynch. About Jim...
Want FREE access to
my daily stock tips
Sign up here:
- Triple Gainers
- Rippers N' Dippers
- Growingest Growers