Share a module between multiple angular apps that

2019-02-13 08:40发布

问题:

This question has been asked before but needs more clarity, is it somehow possible to reuse modules or single components from a angular-cli app to another?

Since its now possible to have multiple apps i one angular-cli project, I took advantage by this to be able to build two different types of bundles for production.

My project looks like this:

src
 |─app-core
 |   |────shared
 |   |       |────share-this.component.ts
 |   |       |────shared.module.ts
 |   |       
 |   |────app.module.ts
 |   |────app-root.component.ts
 |   
 └─app-inspection
     |────app.module.ts (how do I use 'share-this.component.ts' here?)
     |────app-root.component.ts

When importing the SharedModule in the app-inspections AppModule the services isn't provided somehow.

I know a npm-package would solve my problem but I think it should be easier than this.

So, is there anyone who sits on a solution? Otherwise maybe a feature Angular could build?

Link to the other question

回答1:

As Niel Lunn said in his comment, the solution was "Just import relative to the path". So this leads to that you can reuse your modules over apps that resides in one project!

Check here to see how you create multiple apps in one project.