Introduction
Data binding is one of the core features that makes Angular powerful. It controls how data flows between:
The TypeScript class (component logic)
The HTML template (UI)
As a developer, you must understand how Angular synchronizes data between UI and code because this is how you build dynamic and interactive applications.
In this article, we will explore the different types of data binding in Angular using a real-world example.
Real-World Scenario: Building a Customer Profile Form
Imagine we are building a small screen in an application where a user can:
View their name and age
Update information in a form
Click a button to show entered data
To achieve this, we need different types of data binding techniques.
Types of Data Binding in Angular
Angular supports four types of data binding:
Interpolation (One-way: Component to View)
Property Binding (One-way: Component to View)
Event Binding (One-way: View to Component)
Two-Way Binding (Component ↔ View)
1. Interpolation
Interpolation displays dynamic values from the component class into the HTML template using double curly braces.
Example
export class AppComponent {
customerName: string = "Rajesh";
age: number = 28;
}
HTML
<p>Customer Name: {{ customerName }}</p>
<p>Age: {{ age }}</p>
This is one-way data binding from component to UI.
2. Property Binding
Property binding binds a DOM property to a component property.
Example: Disable a button based on a condition.
export class AppComponent {
isDisabled = true;
}
HTML
<button [disabled]="isDisabled">Submit</button>
Here, [disabled] binds the component value to the button property.
3. Event Binding
Event binding allows the UI to send data back to the component using events such as click, input, change, keyup, etc.
Example
export class AppComponent {
message: string = "";
showAlert() {
this.message = "Button clicked successfully.";
}
}
HTML
<button (click)="showAlert()">Click Me</button>
<p>{{ message }}</p>
The (click) triggers the method inside the component.
4. Two-Way Data Binding
Two-way binding keeps the component and template synced automatically.
Angular uses the [(ngModel)] directive from FormsModule.
Step 1: Import FormsModule in app.module.ts.

Join the conversation! Your thoughts help the community grow.