generate component
ng generate component
ng generate c
Creates a new, generic component definition in the given project.
Arguments
name
The name of the component.
string
Options
change-detection
c
The change detection strategy to use in the new component.
string
DefaultDefault
display-block
b
Specifies if the style will contain :host { display: block; }
.
boolean
Defaultfalse
export
The declaring NgModule exports this component.
boolean
Defaultfalse
export-default
Use default export for the component instead of a named export.
boolean
Defaultfalse
flat
Create the new files at the top level of the current project.
boolean
Defaultfalse
inline-style
s
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.
boolean
Defaultfalse
inline-template
t
Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.
boolean
Defaultfalse
module
m
The declaring NgModule.
string
prefix
p
The prefix to apply to the generated component selector.
string
project
The name of the project.
string
selector
The HTML selector to use for this component.
string
skip-import
Do not import this component into the owning NgModule.
boolean
Defaultfalse
skip-selector
Specifies if the component should have a selector or not.
boolean
Defaultfalse
skip-tests
Do not create "spec.ts" test files for the new component.
boolean
Defaultfalse
standalone
Whether the generated component is standalone.
boolean
Defaulttrue
style
The file extension or preprocessor to use for style files, or 'none' to skip generating the style file.
string
Defaultcss
type
Adds a developer-defined type to the filename, in the format "name.type.ts".
string
DefaultComponent
view-encapsulation
v
The view encapsulation strategy to use in the new component.
string