In this article, you will learn in detail about components of Angular.
- What is component and uses of Component?
- What is Template?
- What is Class?
- What is Decorator?
- Default Component Code Explanation
- Step by Step Creation of New Component
What is Component?
The component is the heart of Angular 2 and above versions. Coding in Angular 2 and all above versions goes through components. It is the basic building block of Angular programming. It is a group of Template, Class, and Decorator.
Angular is written in TypeScript so in Angular we follow the full syntax of TypeScript.
Default component name is app.component.ts .
app.component.ts is root component.
With the help of component, we can distribute or break the logic and reuse specific parts into other components of the component.
What is Template?
A template is a group of HTML, directives, and data binding which helps to render UI (view).
What is Class?
The class is the same as similar classes of C# and Java. Here we follow the syntax of TypeScript. Angular is using the full syntax of TypeScript. The class contains properties, variable and method, and functions.
What is Decorator?
Decorator symbol starts with @. With help of @Decorator, we define metadata components like this:
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })

Component Code Explanation
app.component.ts code
- import {
- Component
- } from '@angular/core';
- import {
- member
- } from './member';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })
- export class AppComponent {
- title = 'app';
- }

Roshan MulePosted Jul 3, 2018, 3:26 AM
Hello sir, Thanks for this article. I started learning angular and this article is very helpful for me.
Debasis SahaPosted May 14, 2018, 12:27 PM
Nice Post.... awaiting for the next part...
Manav PandyaPosted May 14, 2018, 10:53 AM
All in one , Great post sir Manoj Kalla