How to determine if a module should be imported into CoreModule or SharedModule

In an application with angular 4, given the following modules:

  • ReactiveFormsModule,
  • FormsModule,
  • HttpModule,
  • TranslateModule, (translation module)
  • AgGridModule.withComponents ([]), (table structure)
  • DatepickerModule.forRoot (), (and generally ngx-bootstrap modules)

Where is the right place to import them: CoreModule or SharedModule ?

Thanks in advance

+4
source share
4 answers

It depends on:

  • these modules define declared types: components, directives or channels.
  • general module used for lazy loading

, Shared. , Core.

, Core. forRoot forChild, DatepickerModule.forRoot().

, :

  • ReactiveFormsModule -
  • FormsModule -
  • HttpModule - core
  • TranslateModule - ​​( )
  • AgGridModule.withComponents([]) -
  • DatepickerModule.forRoot() - core

Angular

+1

. , .

Root/Core

ReactiveFormsModule, FormsModule, HttpModule,

, Root/Core incase, , .

TranslateModule()

.

AgGridModule.withComponents([]), () DatepickerModule.forRoot(), ( ngx-bootstrap)

0

CoreModule AppModule?

0

.

:

, : " ", .

In order to display warnings both on the OR pages and in the models, I would like to place this component both in the application component and in any modalities.

This alert component is also associated with a service that receives alert messages.

I realized that in general, services should be included in the main ones and directives in shared.

But can I import sharedmole also in the app-module, or is this the wrong implementation?

Many thanks

0
source

Source: https://habr.com/ru/post/1686023/


All Articles