How To Create Angular Components In Angular 10/11 Using CLI
In this tutorial, will learn how to create angular components or Use ng generate component using CLI for creating angular components in your project.
we'll learn the very easy command to generate code how to use the
ng generate component command of Angular CLI, or its
ng g c shortcut command, Learn this tutorial.
First of all, If you are new to these how-to, check out how to install and set up an angular project.
How to Use
ng generate component or
ng g c with Angular CLI
Let's assume we want to create an Angular component named About.
Open a new command-line interface ( command prompt ), navigate into the root of your Angular project and run the following command:
ng generate component about
Or you can also run the following Short command:
ng g c about
Angular CLI will generate 4 files for the component in the src/app folder of your project see below:
We can also customize where the component's files are placed.
Angular CLI adds the component to the declarations array of the module.
How to use a component inside another component in Angular?
We saw above how to create a component using angular CLI create components.
This step we learn how to use a component to other component see below:
I hope it can help you...
Leave a Reply