ng generate <schematic> [options] ng g <schematic> [options]
ng generate command generates and/or modifies files based on a schematic. Options are optional parameters.
Sr.No. | Argument & Syntax | Description |
---|---|---|
1 | <schematic> | The schematic or collection:schematic to generate. This option can take one of the following sub-commands −
|
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. |
First move to an angular project created using ng new command and then run the command.
\>Node\>Howcodex> 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)
Here ng generate command has created a new component in our project Howcodex and added this new component entry in app.module.ts.