Angular components are the building blocks of the Angular framework.
Generating (or creating) a component in Angular using the CLI is pretty straight-forward.
To create a component named example
, run the following command in the Angular CLI:
ng generate component example
The command performs the following tasks:
Creates a directory src/app/example
.
Inside that directory four files are generated:
ExampleComponent
ExampleComponent
classThe command also adds the ExampleComponent
as a declaration in the @NgModule
decorator of the src/app/app.module.ts
file.