Angular 2应该使用哪种types的文件夹结构?

我是一名正在开始学习Angular 2的Angular 1开发人员。根据培训材料的不同,有许多不同types的文件夹结构方法。 我将列出下面的每一个,我很想得到人们的意见,我应该使用和为什么。 另外,如果有一种方法没有列出,但是您觉得效果更好,请随时列出。

通过查看所有这些,方法#3几乎是我做我的Angular 1应用程序。

方法1:angular2-quickstart

来源: https : //angular.io/guide/quickstart

文件夹结构:

在这里输入图像说明

方法2:ng-book2

资料来源: https : //www.ng-book.com/2/ (必须付费才能看到文件)

文件夹结构:

在这里输入图像说明

方法3:mgechev / angular2-seed

来源: https : //github.com/mgechev/angular2-seed

文件夹结构:

在这里输入图像说明

官方指南现在在那里。 mgechev/angular2-seed也与它alignment。 见#857 。

Angular 2的应用程序结构

https://angular.io/guide/styleguide#overall-structural-guidelines

所以在做了更多的调查之后,我最终修改了方法3(mgechev / angular2-seed)。

我基本上将组件移动到主级目录,然后每个function都将在其中。

我认为通过function来构build项目是一种实用的方法。 它使项目易于扩展和维护。 这使得项目的每个部分都是完全自治的。 请让我知道您对以下结构的看法: angular度types描述项目结构 – angular度2

来源: http : //www.angulartypescript.com/angular-typescript-project-structure/

我将要使用这个。 与@Marin显示的第三个非常相似。

 app | |___ images | |___ fonts | |___ css | |___ *main.ts* | |___ *main.component.ts* | |___ *index.html* | |___ components | | | |___ shared | | | |___ home | | | |___ about | | | |___ product | |___ services | |___ structures 

最近我一直在使用ng cli,而且find构build代码的好方法真的很难。

迄今为止我见过的效率最高的是mrholek库( https://github.com/mrholek/CoreUI-Angular )。

这个文件夹结构允许你保持你的根项目清洁和结构你的组件,它避免了官方风格指南的冗余(有时是无用的)命名约定。

也就是说,这个结构对于在需要的时候进行分组是非常有用的,并且避免了对于单个文件有30行的导入。

 src | |___ app | | |___ components/shared | | |___ header | | | |___ containers/layout | | |___ layout1 | | | |___ directives | | |___ sidebar | | | |___ services | | |___ *user.service.ts* | | | |___ guards | | |___ *auth.guard.ts* | | | |___ views | | |___ about | | | |___ *app.component.ts* | | | |___ *app.module.ts* | | | |___ *app.routing.ts* | |___ assets | |___ environments | |___ img | |___ scss | |___ *index.html* | |___ *main.ts*