-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusing Information on SharedModule and CoreModule #855
Comments
I'm also confused about the last sentence in Style 04-11.
So, should
@johnpapa Could you please give a quick remark on this? |
The reasons to create those module are different. Core is a place for things which you need only 1 time. I.e. put singleton services, guards there. I also put my navigation and footer because I want my app-folder nice and clean. Import that CoreModule only one time and only in the AppModule. This will keep your AppModule clean. Use the the SharedModule for things that you could use multiple times on one page AND they should/could behave differently. This includes pipes, individual components that should be shared (CardComponent, ListComponent). Also if there are any services that should NOT be singletons but be used individually but shared nevertheless (I cant think of an example here). Usually FormsModule and CommonModule are at least inside the SharedModule (import and export) and I import the SharedModule into all Feature Modules.
|
Hello, I also found these part very confusing in the angular style guide, here I created an article to explain the two modules concepts by bringing you real use cases of what to do with them: CoreModule vs SharedModule Angular style guide Basically, the FormsModule and the CommonModule should be imported and exported back in the SharedModule because they are not needed to be singletons :) |
Documentation for Angular
Questions
CommonModule
andFormsModule
inSharedModule
orCoreModule
?In the documentation, both are OK.
--
CoreModule
into rootAppModule
, so that when a lazy loaded module imports theCodeModule
, it will get the intended app-wide singleton and not a new instance?In the documentation, it suggests to import
CoreModule
into the rootAppModule
, but yet the subsequent lines mentioned that lazy importingCoreModule
will return a new instance.--
CoreModule
? If not, what's the recommendation?Based on the documentation, I thought services are supposed to be in CoreModule, but the last sentence of style 04-11 says otherwise.
References
This stackoverflow question/answer explains it pretty well, but it seemed to contradict (?) the styleguide.
The text was updated successfully, but these errors were encountered: