【发布时间】:2015-04-27 00:21:15
【问题描述】:
我正计划构建一个真正可扩展的 Angular 应用程序。意思是,它将包含许多将由不同的人开发的部分,并且会不时添加新的部分/功能。
我读过一些关于 Angular 在命名和文件夹结构组织方面的最佳实践的文章,例如:
Angularjs code/naming conventions
AngularJS best practices for module declaration?
Angular - Best practice to structure modules
所有这些都集中在文件夹结构和模块命名上。但是控制器和服务的命名约定呢?
例如,如果我有这样的结构:
angular.module("myApp",['myApp.groups','myApp.users']);
angular.module("myApp.groups",['myApp.groups.controllers','myApp.groups.directives']);
angular.module("myApp.users",['myApp.users.controllers','myApp.users.directives']);
我应该将myApp.groups.controllers 模块的控制器命名为myApp.GroupsController 吗?还是只是GroupsController?如果只是GroupsController,如果其他人开发另一个控制器名为GroupsController的组件,可能会发生命名冲突。
那么,为可扩展的大型应用程序命名控制器和服务的最佳做法是什么?
【问题讨论】:
标签: angularjs