AngularJs项目文件结构是怎么样的

这篇文章给大家分享的是有关AngularJs项目文件结构是怎么样的的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

普通的文件组织方式:

  1. app/  

  2. ----- controllers/  

  3. ---------- mainController.js  

  4. ---------- otherController.js  

  5. ----- directives/  

  6. ---------- mainDirective.js  

  7. ---------- otherDirective.js  

  8. ----- services/  

  9. ---------- userService.js  

  10. ---------- itemService.js  

  11. ----- js/  

  12. ---------- bootstrap.js  

  13. ---------- jquery.js  

  14. ----- app.js  

  15. views/  

  16. ----- mainView.html  

  17. ----- otherView.html  

  18. ----- index.html

比较好的文件组织方式如下:

  1. app/  

  2. ----- shared/   // acts as reusable components or partials of our site  

  3. ---------- sidebar/  

  4. --------------- sidebarDirective.js  

  5. --------------- sidebarView.html  

  6. ---------- article/  

  7. --------------- articleDirective.js  

  8. --------------- articleView.html  

  9. ----- components/   // each component is treated as a mini Angular app  

  10. ---------- home/  

  11. --------------- homeController.js  

  12. --------------- homeService.js  

  13. --------------- homeView.html  

  14. ---------- blog/  

  15. --------------- blogController.js  

  16. --------------- blogService.js  

  17. --------------- blogView.html  

  18. ----- app.module.js  

  19. ----- app.routes.js  

  20. assets/  

  21. ----- img/      // Images and icons for your app  

  22. ----- css/      // All styles and style related files (SCSS or LESS files)  

  23. ----- js/       // JavaScript files written for your app that are not for angular  

  24. ----- libs/     // Third-party libraries such as jQuery, Moment, Underscore, etc.  

  25. index.html  

感谢各位的阅读!关于“AngularJs项目文件结构是怎么样的”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!