toddmotto / ama

Ask me anything!
20 stars 3 forks source link

Angular Architecture: Modules <-> Components #37

Closed robert-gruner closed 1 year ago

robert-gruner commented 8 years ago

Hey Todd,

I was studying your updated Angular Styleguide to prepare a major refactoring of a huge application. I really want to rethink our architecture and use modules which again are composed of hierarchical components.

You can assume that we have a top level navigation and separate subnavigations for each section. Furthermore those two hierarchies of navigation views can be filtered. So far all of this is put into one big angular module. This is not maintainable any more.

Can you give me some hints how to start restructuring it? Just by reading the Styleguide I could not get a real feeling for the role and relation of and between modules and components.

My biggest concern is the communication between the soon-to-be created modules since this was just not necessary only having one big module. How do I ensure the exchange of data and the routing between those new modules specifically in Angular 1.X.

Let me thank you for your great Styleguide and also in advance for your response.

Robert

toddmotto commented 8 years ago

If you think about modules, these should ideally be "features". If you had a contacts manager, you can have an auth module, that's a feature of the app that can be standalone that you can remove, and drop in elsewhere with little wiring together to a new app. Any questions shoot :)

robert-gruner commented 8 years ago

Sorry wrong button. :D

I was more referring to the relation between angular.module and angular.component. I saw real-life applications where every component is put into its own module - so you can integrate them where you need via the requires array. Does this sound meaningful to you? Can be that I am overestimating the importance of angular.modules and overthinking it a little. But I felt that the styleguide could be a bit more precise at this point.