简体   繁体   中英

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.

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. 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.

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.

Am I correct ? Do you have any good suggestion to deploy two application in an easier way ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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