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
Only one root module can exist in an Angular application.
To get started, go ahead and install bit-cli, then head over to the project from which to share the components, and initialize a bit workspace. Then, head over to bit. dev and create a free account. Then, create a collection to host your shared components.
Creating shared modules allows you to organize and streamline your code. You can put commonly used directives, pipes, and components into one module and then import just that module wherever you need it in other parts of your application.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With