What is the role of Angular core module?

Pedro Arantes picture Pedro Arantes · Mar 3, 2018 · Viewed 11.9k times · Source

I read an article about organizing folders in Angular and the author uses one called core, in which he creates the core module and insert only services which will be called once.

Currently, I'm working on a project whereupon I adopted the structure recommended by the article. Inside my core folder/module I created a module called api:

\app
  \core
    \api
    ...
  \shared
  ...

My question is: as the api is a module, I was wondering why not remove it from core and put in app folder?

\app
  \api
  \core
  \shared
  ...

Angular itself has core module too (where we import ngModule, Injectable...) and I'd like to know what is its role.

Answer

Sajeetharan picture Sajeetharan · Mar 3, 2018

Your CoreModule contains code that will be used to instantiate your app and load some core functionality.

To get more idea on this read Core Module