生成模組
要新增名為 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 |