新しいAngular2
プロジェクトを開始する予定で、Angular2
アプリケーションの最適な構造を理解しようとしています。私はhome
,auto-galleries
,nearest-galleries
,brands
,cars
およびselected-car
のようなページを持っています。そして、ナビゲーション順序は、最善のアプローチについてはAngular2 - Project Structure
home -> auto-galleries -> nearest-galleries
または
home -> brands -> cars -> selected-car
で、私はページごとにコンポーネントまたはモジュールを使用する必要がありますか?モジュールがより良いアプローチの場合は、階層モジュールを使用するか、すべてルートモジュールの同じレベルで使用する必要がありますか?
例えば、以下の構造どのように良いです:
app
├--- app.module.ts
├--- app.component.ts
├--- home.html
├--- brands
| ├--- brands.module.ts
| ├--- brands.component.ts
| ├--- brands.html
| ├--- cars
| ├--- cars.module.ts
| ├--- cars.component.ts
| ├--- cars.html
| ├--- selected-car
| ├--- selected-car.module.ts
| ├--- selected-car.component.ts
| ├--- selected-car.html
|
├--- auto-galleries
├--- auto-galleries.module.ts
├--- auto-galleries.component.ts
├--- auto-galleries.html
├--- nearest-galleries
├--- nearest-galleries.module.ts
├--- nearest-galleries.component.ts
├--- nearest-galleries.html
それとも、この構造が優れている:
app
├--- app.module.ts
├--- app.component.ts
├--- home.html
├--- brands
| ├--- brands.module.ts
| ├--- brands.component.ts
| ├--- brands.html
|
├--- cars
| ├--- cars.module.ts
| ├--- cars.component.ts
| ├--- cars.html
|
├--- selected-car
| ├--- selected-car.module.ts
| ├--- selected-car.component.ts
| ├--- selected-car.html
|
├--- auto-galleries
| ├--- auto-galleries.module.ts
| ├--- auto-galleries.component.ts
| ├--- auto-galleries.html
|
├--- nearest-galleries
├--- nearest-galleries.module.ts
├--- nearest-galleries.component.ts
├--- nearest-galleries.html
注:これは単なる一例であり、私のアプリケーションは、より優れたモジュール構造に適合:)