CLI

generate component

Command
ng generate component
ng generate c

Creates a new, generic component definition in the given project.

Arguments

name

The name of the component.

Value Typestring

Options

change-detection
Aliasc

The change detection strategy to use in the new component.

Value TypestringDefaultDefault
display-block
Aliasb

Specifies if the style will contain :host { display: block; }.

Value TypebooleanDefaultfalse
export

The declaring NgModule exports this component.

Value TypebooleanDefaultfalse
export-default

Use default export for the component instead of a named export.

Value TypebooleanDefaultfalse
flat

Create the new files at the top level of the current project.

Value TypebooleanDefaultfalse
inline-style
Aliass

Include styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file.

Value TypebooleanDefaultfalse
inline-template
Aliast

Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.

Value TypebooleanDefaultfalse
module
Aliasm

The declaring NgModule.

Value Typestring
prefix
Aliasp

The prefix to apply to the generated component selector.

Value Typestring
project

The name of the project.

Value Typestring
selector

The HTML selector to use for this component.

Value Typestring
skip-import

Do not import this component into the owning NgModule.

Value TypebooleanDefaultfalse
skip-selector

Specifies if the component should have a selector or not.

Value TypebooleanDefaultfalse
skip-tests

Do not create "spec.ts" test files for the new component.

Value TypebooleanDefaultfalse
standalone

Whether the generated component is standalone.

Value TypebooleanDefaulttrue
style

The file extension or preprocessor to use for style files, or 'none' to skip generating the style file.

Value TypestringDefaultcss
type

Adds a developer-defined type to the filename, in the format "name.type.ts".

Value TypestringDefaultComponent
view-encapsulation
Aliasv

The view encapsulation strategy to use in the new component.

Value Typestring
Jump to details