在驻留在同一项目中的多个角度应用程序之间共享模块 [英] Share a module between multiple angular apps that resides in the same project

查看:92
本文介绍了在驻留在同一项目中的多个角度应用程序之间共享模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题曾经被问过,但需要更清楚地说明,是否可以以某种方式将模块或单个组件从angular-cli应用程序重用到另一个?

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?

由于现在可以在一个angular-cli项目中拥有多个应用程序,因此我利用这一优势可以构建两种不同类型的捆绑软件进行生产.

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.

我的项目如下:

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

在应用程序检查AppModule中导入SharedModule时,未以某种方式提供服务.

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

我知道一个npm-package可以解决我的问题,但是我认为这应该比这容易得多.

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

那么,有谁坐在解决方案上吗?否则,也许Angular可以构建一个功能?

链接到其他问题

推荐答案

正如Niel Lunn在他的评论中所说,解决方案是仅相对于路径导入".因此,这导致您可以在驻留在一个项目中的应用程序上重用模块!

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.

这篇关于在驻留在同一项目中的多个角度应用程序之间共享模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆