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

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

问题描述

之前已经问过这个问题,但需要更清楚地说明,是否可以以某种方式将模块或单个组件从 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

在 app-inspections 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.

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

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