AngularJS 文件夹结构 [英] AngularJS Folder Structure

查看:40
本文介绍了AngularJS 文件夹结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何为大型且可缩放的 AngularJS 应用程序布局文件夹结构?

How do you layout a folder structure for a large and scaleable AngularJS application?

推荐答案

左侧是按类型组织的应用程序.对于较小的应用程序来说还不错,但即使在这里,您也可以开始发现找到所需内容变得更加困难.当我想查找特定视图及其控制器时,它们位于不同的文件夹中.如果您不确定如何组织代码,最好从这里开始,因为很容易转向右侧的技术:按功能结构.

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.

在右侧,项目按功能组织.所有布局视图和控制器都放在布局文件夹中,管理内容放在 admin 文件夹中,所有区域使用的服务放在 services 文件夹中.这里的想法是,当您寻找使功能起作用的代码时,它位于一个地方.服务有点不同,因为它们服务"许多功能.一旦我的应用开始成形,我就喜欢它,因为它对我来说变得更容易管理了.

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-结构/

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

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

这篇关于AngularJS 文件夹结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆