Create Components In Angular 5
- Step 1 – – – – To create components, go to src/app as you can see the folder structure.
- To create different components, use the following syntax.
- Also, specify the entry of each address bar path and the component to render into the router-outlet.
- Step 5 – – – – Now, run the application by using the below command.
- I am going to create three different components as home, blogs, & contact.
In this article, we will learn what a component is and how to create components.
@CsharpCorner: Create Components In #Angular5 by @Rupesh_kahane cc @CsharpCorner #Angular
We have already seen how to create your first Angular application in my previous article, i.e., Getting started with Angular 5. Now, in this article, we will learn what a component is and how to create components.
What is a component?
Every Angular application has at least one component that is used to display the data on the View.
The component contains metadata like animation effect, style to apply the components, template, input-output, import etc.
These are the main building blocks of an Angular application.
When we create any component, it gets defined in NgModule.
Suppose you are going to develop a simple application which contains home page, logo – menu list – footer etc.; the blogs page contains blogs list, contact information about the author etc. So we are going to create these components.
To create components, go to src/app as you can see the folder structure. Now, by clicking the mouse as shown in the below image, type cmd then press Enter key, so the command prompt will open.
To create different components, use the following syntax.
This will create the component. I am going to create three different components as home, blogs, & contact.
In the home component, I am going to write some HTML code which contains logo & menu list.
In blog & contact, I am going to write just a…