I am an Angular 1 developer that is starting to learn about Angular 2. There are a lot of different types of folder structure methods depending on the training material. I am
The official guideline is there now. mgechev/angular2-seed
had alignment with it too. see #857.
https://angular.io/guide/styleguide#overall-structural-guidelines
Here's mine
app
|
|-- shared (for html shared between modules)
| |
| |-- layouts
| | |
| | |-- default
| | | |-- default.component.ts|html|scss|spec.ts
| | | |-- default.module.ts
| | |
| | |-- fullwidth
| | |-- fullwidth.component.ts|html|scss|spec.ts
| | |-- fullwidth.module.ts
| |
| |-- components
| | |-- footer
| | | |-- footer.component.ts|html|scss|spec.ts
| | |-- header
| | | |-- header.component.ts|html|scss|spec.ts
| | |-- sidebar
| | | |-- sidebar.component.ts|html|scss|spec.ts
| |
| |-- widgets
| | |-- card
| | |-- chart
| | |-- table
| |
| |-- shared.module.ts
|
|-- core (for code shared between modules)
| |
| |-- services
| |-- guards
| |-- helpers
| |-- models
| |-- pipes
| |-- core.module.ts
|
|-- modules (each module contains its own set)
| |
| |-- dashboard
| |-- users
| |-- books
| |-- components -> folders
| |-- models
| |-- guards
| |-- books.service.ts
| |-- books.module.ts
|
|-- material
| |-- material.module.ts
If project is small and will remain small, I would recommend to structure by type (Method 2: ng-book2)
app
|- components
| |- hero
| |- hero-list
| |- villain
| |- ...
|- services
| |- hero.service.ts
| |- ...
|- utils
|- shared
If project will grow you should structure your folders by domain (Method 3: mgechev/angular2-seed)
app
|- heroes
| |- hero
| |- hero-list
| |- hero.service.ts
|- villains
| |- villain
| |- ...
|- utils
|- shared
Better to Follow official docs.
https://angular.io/guide/styleguide#application-structure-and-ngmodules
I am going to use this one. Very similar to third one shown by @Marin.
app
|
|___ images
|
|___ fonts
|
|___ css
|
|___ *main.ts*
|
|___ *main.component.ts*
|
|___ *index.html*
|
|___ components
| |
| |___ shared
| |
| |___ home
| |
| |___ about
| |
| |___ product
|
|___ services
|
|___ structures
I think structuring the project by functionalities is a practical method. It makes the project scalable and maintainable easily. And it makes each part of the project working in a total autonomy. Let me know what you think about this structure below: ANGULAR TYPESCRIPT PROJECT STRUCTURE – ANGULAR 2
source : http://www.angulartypescript.com/angular-typescript-project-structure/
I suggest the following structure, which might violate some existing conventions.
I was striving to reduce name redundancy in the path, and trying to keep naming short in general.
So there is no/app/components/home/home.component.ts|html|css.
Instead it looks like this:
|-- app
|-- users
|-- list.ts|html|css
|-- form.ts|html|css
|-- cars
|-- list.ts|html|css
|-- form.ts|html|css
|-- configurator.ts|html|css
|-- app.component.ts|html|css
|-- app.module.ts
|-- user.service.ts
|-- car.service.ts
|-- index.html
|-- main.ts
|-- style.css