我使用 Angular 种子(带有文件 index-async.html(异步加载依赖项))来启动我的 Web 项目,但我的 Controller 需要进行一些重组。我现在有 3 个充满 Controller 的文件(700 多行)。如果我将它们重新组织成 10 个文件(将来会更多),是否有一种优雅的方式来加载我的 Controller 。
此外,更多的文件意味着更少的合并冲突(是的!!!)
提前致谢
最佳答案
我广泛使用 angular.module().controller()
语法按模块对我的 Controller 进行分组,这极大地改进了我的 Angular 代码的组织。作为一个额外的好处,您的 Controller 不再是全局 namespace 函数。
您可以在 Module API documentation 中阅读更多内容.
关于javascript - Angular : Code organisation of controllers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11955466/