Sak*_*uto 23 angular-cli angular
我正在使用基于Angular-CLI骨架的Angular 2应用程序,我习惯用一个目录按模块构建我的src文件夹,并且每个组件都与该模块在同一文件夹中相关.
src
app
documents
document-list.component.ts
document-list.component.html
documents.component.ts
documents.component.html
document.module.ts
app.component.ts
app.module.ts
main.ts
Run Code Online (Sandbox Code Playgroud)
现在我正在使用Angular-CLI,我想利用每个功能,但是当我生成一个新组件时,无论如何,当我只想放置它时,它会继续为我的组件创建一个新文件夹在相关文件夹内.
src
app
documents
document-list
document-list.component.ts
document-list.component.html
documents.component.ts
documents.component.html
document.module.ts
app.component.ts
app.module.ts
main.ts
Run Code Online (Sandbox Code Playgroud)
是否有可能保留我以前的结构,这是一种不好的做法吗?该指南建议避免无用的目录深度,所以我有点不安.
Bro*_*cco 47
假设您位于应用程序的根目录中,并希望在src/app/documents上面显示内部创建组件.您可以使用该--flat选项在不创建目录的情况下创建组件.要创建上面的组件,请使用以下命令:
ng generate component document-list --flat
Run Code Online (Sandbox Code Playgroud)
Gma*_*man 21
使用angular-cli,你可以运行ng g component documents/document-list它,它将创建你需要的结构,(假设app是你的应用程序的根).
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
24275 次 |
| 最近记录: |