简体   繁体   English

在Angular应用之间共享脚本

[英]Share scripts between Angular apps

Good morning, I'm trying to write two different Angular2 apps that share the same business logic but are different in layout, style and animations. 早上好,我试图编写两个不同的Angular2应用程序,它们共享相同的业务逻辑,但布局,样式和动画不同。

What i would do with a "classic" html + css + js website would be to create my custom html + css + js and reference the common ones. 我对“经典”的html + css + js网站所做的工作是创建我的自定义html + css + js并引用常见的HTML + css + js。 The advantage of this solution is the possibility to fix bugs or modify the shared code easily. 该解决方案的优点是可以轻松修复错误或修改共享代码。

So for example in web website structure like this one : 因此,例如在这样的网站结构中:

└─┬www
    |
    ├─┬WebSite1 
    | └ site1.html
    | └ style1.css
    | └ script1.js
    ├─┬WebSite2
    | └ site2.html
    | └ style2.css
    | └ script2.js
    ├─┬Shared 
    | └ shared.js

I can reference "shared.js" from website1 and website2. 我可以从website1和website2引用“ shared.js”。

With Angular i understand that i have build two different applications, maybe sharing "library" code, but if I have to modify some shared code I have to rebuild the two applications. 使用Angular,我了解到我已经构建了两个不同的应用程序,也许共享“库”代码,但是如果我必须修改一些共享的代码,则必须重新构建两个应用程序。

Am I correct ? 我对么 ? Do you have any good suggestion to deploy two application in an easier way ? 您是否有以更好的方式部署两个应用程序的好建议?

有多种方式来组织Angular项目,最值得注意的是按功能(即产品功能)和按文件类型(即html的目录不同,服务的目录不同,文件较少等)。是按文件类型的,因此您可以从需要此逻辑的任何其他角度应用程序实例中包含业务逻辑模块,该模块可能包含相关services

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM