📜  Angular CLI-ng生成命令

📅  最后修改于: 2020-10-27 02:39:55             🧑  作者: Mango


句法

ng generate  [options]
ng g  [options]

ng generate命令基于原理图生成和/或修改文件。选项是可选参数。

争论

Sr.No. Argument & Syntax Description
1

The schematic or collection:schematic to generate. This option can take one of the following sub-commands −

  • appShell
  • application
  • class
  • component
  • directive
  • enum
  • guard
  • interceptor
  • interface
  • library
  • module
  • pipe
  • service
  • serviceWorker
  • webWorker

选件

Sr.No. Option & Syntax Description
1 –defaults=true|false When true, disables interactive input prompts for options with a default.
2 –dryRun=true|false

When true, runs through and reports activity without writing out results.

Default: false.

Aliases: -d.

3 –force=true|false

When true, forces overwriting of existing files.

Default: false.

Aliases: -f.

4 –help=true|false|json|JSON

Shows a help message for this command in the console.

Default: false.

5 –interactive=true|false When false, disables interactive input prompts.

首先移至使用ng new命令创建的角度项目,然后运行该命令。

\>Node\>TutorialsPoint> ng generate component goals
CREATE src/app/goals/goals.component.html (20 bytes)
CREATE src/app/goals/goals.component.spec.ts (621 bytes)
CREATE src/app/goals/goals.component.ts (271 bytes)
CREATE src/app/goals/goals.component.css (0 bytes)
UPDATE src/app/app.module.ts (471 bytes)

在这里ng generate命令在我们的项目TutorialsPoint中创建了一个新组件,并将此新组件条目添加到app.module.ts中。