简体   繁体   English

负载角度依赖性之间的区别是什么?共享模块的最佳方法是什么?

[英]What are the differences between load angular dependencies and what is the best way to share modules?

What is the difference between those ways of load modules? 这些加载模块方式之间有什么区别?

angular.module('CoreApp', ['...','...','...','...']); //parent module
angular.module('MainApp1', ['CoreApp']);  //child 1
angular.module('MainApp2', ['CoreApp']);  //child 2

angular.module('CoreApp', ['...','...','...','...','MainApp1','MainApp2']); //parent module
angular.module('MainApp1', []);  //child 1
angular.module('MainApp2', []);  //child 2

... Apart from that, maybe I'm doing it wrong. ...除此之外,也许我做错了。 My mainApps are going to run in different domains(mainapp1.com and mainapp2.com). 我的mainApps将在不同的域(mainapp1.com和mainapp2.com)中运行。 I have some headers(login,menus) and footers that i want to share it instead of copying and changing them on each module. 我有一些标题(登录,菜单)和页脚,我想共享它,而不是在每个模块上复制和更改它们。 Of course i have directives and services(such a translate services). 当然,我有指令和服务(例如翻译服务)。

I don't know what is the best way to do this. 我不知道什么是最好的方法。 I thought on create a private bower package with the coreapp and load it in the other projects. 我考虑过使用coreapp创建一个专用的Bower包,并将其加载到其他项目中。 I also want that the development process will be much confortable as possible. 我也希望开发过程尽可能轻松。

Is there any better idea? 有更好的主意吗?

Thanks 谢谢

  1. There will be only one main module per application. 每个应用程序只有一个主模块。
  2. You can create sub modules based on the parent module. 您可以基于父模块创建子模块。
  3. I don't think you can run sub modules in different domain, because of the fact that sub modules will loaded/instantiated after the main module. 我认为您不能在不同的域中运行子模块,因为子模块将在主模块之后加载/实例化。

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

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