您可以将模块视为应用程序不同部分的容器 - 控制器、服务、过滤器、指令等。例如,要访问容器,只需调用其模块名称
//file.4
angular.module("theModule",[]);
现在您已经在 Angular 中声明了主模块,现在您可以使用 Angular 从任何地方访问 mainModule
//file 1
angular.module("theModule").controller("MyController",[function(){...}]);
//file 2
angular.module("theModule").controller("MyOtherController",[function(){...}]);
//file 3
angular.module("mainModule").factory("MyFactory",[function(){...}]);
查看文档以获取更多信息。 https://docs.angularjs.org/guide/module
我还建议阅读 Google 的风格指南和约定手册 http://google-styleguide.googlecode.com/svn/trunk/angularjs-google-style.html
另请阅读有关设置应用程序结构以实现可维护性的信息 http://www.johnpapa.net/angular-app-structuring-guidelines/