且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

AngularJS文件夹结构

更新时间:2021-08-23 01:25:20

AngularJS文件夹结构

在左边,我们有按类型组织的应用程序。不算太糟糕较小的应用程序,但即使在这里,你可以开始看到它变得更加困难找到你在找什么。当我想找到一个特定的视图及其控制器,它们在不同的文件夹中。它可以很好地从这里开始,如果你不知道怎么回事组织code,因为它是很容易转移到右边的技术:通过功能结构

On the left we have the app organized by type. Not too bad for smaller apps, but even here you can start to see it gets more difficult to find what you are looking for. When I want to find a specific view and its controller, they are in different folders. It can be good to start here if you are not sure how else to organize the code as it is quite easy to shift to the technique on the right: structure by feature.

在右侧的项目是由功能组织。所有的布局视图和控制器走在布局文件夹时,管理内容的推移在管理文件夹中,被所有的领域中使用的服务,在服务的文件夹中去。这里的想法是,当你正在寻找code,使一个功能的工作,它坐落在一个地方。服务是因为他们服务的许多功能有点不同。我喜欢这一次我的应用程序启动,因为它成为一个更容易管理,我初具规模。

On the right the project is organized by feature. All of the layout views and controllers go in the layout folder, the admin content goes in the admin folder, and the services that are used by all of the areas go in the services folder. The idea here is that when you are looking for the code that makes a feature work, it is located in one place. Services are a bit different as they "service" many features. I like this once my app starts to take shape as it becomes a lot easier to manage for me.

一个写得很好的博客文章:http://www.johnpapa.net/angular-growth-structure/

A well written blog post: http://www.johnpapa.net/angular-growth-structure/

示例应用程序: https://github.com/angular-app/angular-app

Example App: https://github.com/angular-app/angular-app