Component generator

This is the documentation for Angular 8.
You can switch to the latest version Angular 9.
ng generate component [name] [--[argument]=[value]]
ng generate c

Create an Angular component.

Options

--changeDetection#

Specifies the change detection strategy.

Type string
Values Default, OnPush
Default Default
Aliases c

--entryComponent#

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

Type boolean
Default false

--export#

Specifies if declaring module exports the component.

Type boolean
Default false

--flat#

Flag to indicate if a dir is created.

Type boolean
Default false

--inlineStyle#

Specifies if the style will be in the ts file.

Type boolean
Default false
Aliases s

--inlineTemplate#

Specifies if the template will be in the ts file.

Type boolean
Default false
Aliases t

--lintFix#

Specifies whether to apply lint fixes after generating the component.

Type boolean
Default false

--module#

Allows specification of the declaring module.

Type string
Aliases m

--prefix#

The prefix to apply to generated selectors.

Type string
Aliases p

--project#

The name of the project.

Type string
Default projectName

--selector#

The selector to use for the component.

Type string

--skipImport#

Flag to skip the module import.

Type boolean
Default false

--spec#

Specifies if a spec file is generated.

Type boolean
Default true

--styleext#

The file extension to be used for style files.

Type string
Default css

--viewEncapsulation#

Specifies the view encapsulation strategy.

Type string
Values Emulated, Native, None
Default Emulated
Aliases v