生成模块
要添加名为 GuestModule 的模块,请运行:
$ ng g m guest
installing module
create src/app/guest/guest.module.ts
- 要启用
.spec文件创建,请添加--spec或-sp标志
$ ng g m guest --spec
installing module
create src/app/guest/guest.module.spec.ts
create src/app/guest/guest.module.ts
- 要启用路由,请添加
--routing或-r标志
$ ng g m guest --routing
installing module
create src/app/guest/guest-routing.module.ts
create src/app/guest/guest.module.ts
你还可以组合上面列出的标志。例如,要使用路由和规范创建模块,请使用以下命令。
$ ng g m guest -sp -r
installing module
create src/app/guest/guest-routing.module.ts
create src/app/guest/guest.module.spec.ts
create src/app/guest/guest.module.ts
所有 generate module 标志:
| 描述 | 标志 | 缩短 | 默认值 |
|---|---|---|---|
启用 .spec 文件创建 |
--spec |
-sp |
false |
| 启用路由 | --routing |
-r |
false |