What is an Angular Component?
An Angular Component is the main building block of an Angular application.
Think of a component as:
-
HTML (UI) → what the user sees
-
TypeScript (Logic) → how the data works
-
CSS (Style) → how it looks
👉 Every screen, page, or section in Angular is a component.
Structure of an Angular Component
A component has 3 main parts:
-
Component Class (TypeScript)
-
Template (HTML)
-
Decorator (
@Component)
Example:
import { Component } from '@angular/core';
@Component({
selector: 'app-user',
templateUrl: './user.component.html',
styleUrls: ['./user.component.css']
})
export class UserComponent {
name: string = 'Shiva';
age: number = 25;
}
Explanation
| Part | Meaning |
|---|---|
@Component | Tells Angular this is a component |
selector | Used as HTML tag <app-user> |
templateUrl | HTML file |
styleUrls | CSS file |
class UserComponent | Holds data & logic |
Using a Component
Once created, use it like a custom HTML tag:

0 Comments
POST Answer of Questions and ASK to Doubt