generate component

Create an Angular component.

Overview

ng generate component <name> [options] or ng g c <name> [options] generates a component.

Arguments

schematic (optional) The schematic or collection:schematic to generate.

name (required) The name of the component.

Options

--change-detection (alias -c) Specifies the change detection strategy.

--dryRun (alias -d) Run through without making any changes.

--entry-component Specifies if the component is an entry component of declaring module.

--export Specifies if declaring module exports the component.

--flat Flag to indicate if a dir is created.

--force (alias -f) Forces overwriting of files.

--inline-style (alias -s) Specifies if the style will be in the ts file.

--inline-template (alias -t) Specifies if the template will be in the ts file.

--lint-fix Specifies whether to apply lint fixes after generating the component.

--module (alias -m) Allows specification of the declaring module.

--prefix (alias -p) The prefix to apply to generated selectors.

--project The name of the project.

--selector The selector to use for the component.

--skip-import Flag to skip the module import.

--spec Specifies if a spec file is generated.

--styleext The file extension to be used for style files.

--view-encapsulation (alias -v) Specifies the view encapsulation strategy.

Last updated