In this article we will discuss what is angular nested components. If you miss our previous article then please follow Angular Template VS Templateurl.
What are nested components in Angular ?
The Angular framework allows us to use an angular component within another angular component that is called as Angular Nested Components. The outside component is called the parent component and the inner component is called the child component.
AppComponent: The AppComponent is used as parent component.
EmployeeComponent: The EmployeeComponent is used to display the employee details. This is child component. As this is the child component, it should be nested inside the AppComponent i.e. in the parent component.
Let's create a angular application and we will discuss how to implement nested components. If you are new to angular then check the article how to create angular 8 project using Angular CLI
After creating the sample app, create a new component named as employee like below;
ng g c employee
Open the employee.component.ts file add the class like below;
Open the employee.component.html file and add the below html.
If you open the app.module.ts file in root folder then you can find that the employee component automatically register in module.ts to access the typescript file.What are nested components in Angular ?
The Angular framework allows us to use an angular component within another angular component that is called as Angular Nested Components. The outside component is called the parent component and the inner component is called the child component.
AppComponent: The AppComponent is used as parent component.
EmployeeComponent: The EmployeeComponent is used to display the employee details. This is child component. As this is the child component, it should be nested inside the AppComponent i.e. in the parent component.
Let's create a angular application and we will discuss how to implement nested components. If you are new to angular then check the article how to create angular 8 project using Angular CLI
After creating the sample app, create a new component named as employee like below;
ng g c employee
Open the employee.component.ts file add the class like below;
Open the employee.component.html file and add the below html.
In the app.component.ts file add a header string like below;
Now open the app.component.html file and add the employee component like below;
Now run the application using command ng s --o
You can see employee info was added |
</> Find the Source Code in Github.com/CoreProgramm/
Summary
Post a Comment