Today, we will explain to you how to create a component in angular 11(Angular 11 Create Component Example). In this example, you will learn how to create components using the ng generate component command.
You can easily create the new components using the Angular CLI command. so you can follow steps for creating components using Angular CLI.
Create new angular app
We will create a new angular app using the following command.
ng new myapp
ng generate component
first, open the command prompt or terminal and create the component using the below command.
ng generate component home
You can also execute the following command.
ng g c home
The above command will generate 4 files in the “src/app” directory.
If want to add code or write edit some code in these 4 files then you can do that. when are you create the component using the command line then that component automatically added in the app.module.ts file.