[英]Request/Response will be converted to different naming conventions, without my knowledge/willing
[英]Angular 4 file naming conventions
我正在從AngularJS遷移到Angular4,我看到的示例遵循命名約定。 我主要討論組件。 似乎有一個app / components文件夾,然后是每個組件下面的單獨文件夾。 這看似合理。 但是在我看到的組件“我的”的例子中,文件名是mine.component.html,mine.component.ts和mine.component.css
有這么好的理由嗎? 它位於components文件夾下的事實似乎使得.component部分的使用無關緊要。
此外,如果我有一個組件本身包含組件,並且那些組件只能由該組件使用,那么將它們放在app / components下是否有意義。 把它們放在app / components / mine中會不會更有意義?
一般來說,我傾向於遵循我觀察到的模式,因為我認為通常有一個很好的理由,但我看不出這些約定的任何特殊原因。
請讓我直截了當。
我所看到的使用Angular CLI聲稱“ 它已經遵循我們的最佳實踐! ”,每個組件都會在您存儲主AppModule
的同一文件夾中接收它自己的文件夾。
但是,正如您所提到的,對於嵌套文件夾,我已經將其視為一種練習,但不一定是嵌套組件。 您可以將組件放入模塊中,而不是將組件放入組件中。
下面是一個示例目錄......
└── src
└── app
├── module-one
│ ├── component-one
│ │ ├── component-one.component.html
│ │ └── component-one.component.ts
│ ├── component-two
│ │ ├── component-two.component.html
│ │ └── component-two.component.ts
│ └── module-one.module.ts
├── module-two
│ ├── component-three
│ │ ├── component-three.component.html
│ │ └── component-three.component.ts
│ ├── component-four
│ │ ├── component-four.component.html
│ │ └── component-four.component.ts
│ └── module-two.module.ts
├── app-routing.module.ts
├── app.component.html
├── app.component.ts
└── app.module.ts
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.