Angular 2 & NgModules for SubComponents

20 views
Skip to first unread message

F. Zafer KAYIKÇILAR

unread,
Aug 22, 2016, 10:50:11 AM8/22/16
to AngularJS
I'm pretty new to Angular and these RC changes really hard for me. Like NgModules. I understood how to put main components to AppModule. It's ok but for example i have sub components that are used in Home component.

Should i make a HomeModule (including SubHomeComponent1, SubHomeComponent2) and import it to AppModule
OR
Should i put everything (including HomeComponent, SubHomeComponent1, SubHomeComponent2 etc.) to AppModule? 

_ Maxxx_

unread,
Aug 23, 2016, 8:04:56 PM8/23/16
to AngularJS
I think the first is the preferred option - your HomeModule groups like components together. Later you may have an "AwayModule" containing SumAwayComponent1 etc. which you will then import into AppModule.
Thus, when Appmodule loads, it can lazy-load either Home or Away depending on whatever business logic separates the two.

.\\axxx

_ Maxxx_

unread,
Aug 23, 2016, 8:07:31 PM8/23/16
to AngularJS
I think the first is the preferred option - your HomeModule groups like components together. Later you may have an "AwayModule" containing SumAwayComponent1 etc. which you will then import into AppModule.
Thus, when Appmodule loads, it can lazy-load either Home or Away depending on whatever business logic separates the two.

.\\axxx

On Tuesday, 23 August 2016 00:50:11 UTC+10, F. Zafer KAYIKÇILAR wrote:
Reply all
Reply to author
Forward
0 new messages