我是新来的,所以请忍受我.我正在阅读另一天的文章/文档,突出显示了在应用程序中构建模块的最佳方法,只能轻松记住它.
- App.controllers
- App.services
- ....
- angular.module('App',[App.controllers,App.services ...);
这个代码示例很可能是不正确的,但重点是将控制器,服务等组合在一个命名空间中.
有人可以扩大这种做法吗?
企业项目组织
我组织我的角度项目的方式是:
- /app
- /img # application-level images
- /css # application-level css styles
- /js # application-level javascripts
- /modules # application modules
- /gallery # independent module with its own infrastructure
- /controllers # gallery module's controllers
- /css # gallery module's css styles
- /directives # gallery module's directives
- /img # gallery module's images
- /filters # gallery module's filters
- /services # gallery module's services
- /views # gallery module's views (htmls)
- / ... # other gallery module component folders
- galleryMod.js # the module itself
- /user # independent module with its own infrastructure
- /controllers # user module's controllers
- / ... # other user module component folders
- userMod.js # the module itself
- / ... # other modules
- / ... # other application-level folders
- index.html
替代企业项目组织(简化)
- /app
- /img # application-level images
- /css # application-level css styles
- /js # application-level javascripts
- /modules # application modules
- /gallery # independent module with its own infrastructure
- /js # gallery module's javascripts (includes
- # services.js,directives.js,filters.js,...)
- /css # gallery module's css styles
- /img # gallery module's images
- /views # gallery module's views (htmls,"partials")
- / ... # other gallery module component folders
- galleryMod.js # the module itself
- /user # independent module with its own infrastructure
- /controllers # user module's controllers
- / ... # other user module component folders
- userMod.js # the module itself
- / ... # other modules
- / ... # other application-level folders
- index.html
中间项目组织(无模块)
- /app
- /img # application's images
- /css # application's css styles
- /controllers # application's controllers
- /directives # application's directives
- /filters # application's filters
- /services # application's services
- /views # application's views (htmls)
- / ... # other component folders
- index.html
简单的项目组织(就像种子)
- /app
- /img # application's images
- /css # application's css styles
- /js # application's javascripts (includes
- # services.js,...)
- /views # application's views (htmls),e.g. partials
- / ... # other component folders
- index.html
使用您的项目需要组织的方式,不要选择不必要的项目复杂化的方式.