Search code examples
angularmodulereusabilitycode-reusemodularity

Multiple Angular Apps using a common folder of modules


What I am trying to achieve is reusable modules. However we have many applications that are different but all require some of the same basic building blocks. For example a module for graphs would be good for code reusability as all applications use the same graphs.

This being said I can only find ways to create a module inside an application. This is fine but does not work well in for our needs as it needs to be used in another application as well. What I would like is something like the following:

Projects:
  ProjectOne
  ProjectTwo
  ModuleGraphs
    Graph 1 component
    Graph 2 component
    graph service
    graph directive
    graph module
  ModuleCommon
    Table Component
      table html
      table css
    common module

I remember seeing a similar way in Angular 1.x but not sure how to go about it in Angular 2+.


Solution

  • The ng generate library command from the Angular CLI will create an Angular library project. This is available in Angular 6 onwards.