Interpolation in Angular is a one-way data binding technique that allows you to display dynamic data from your component class directly within your HTML templates.
It provides an expressive and intuitive way to embed component data or expressions using double curly braces {{ }}, which Angular evaluates and renders as text in the view.
Interpolation acts as a bridge between the component logic (TypeScript) and the template (HTML).
It helps render values dynamically, making your UI reflect the current state of your component data.
-
Data flows from the component to the view.
-
When component data changes, the template updates automatically.
-
However, changes in the view do not directly affect the component’s data through interpolation.
-
Component properties
-
Method calls
-
Simple arithmetic operations
-
String literals with JavaScript methods applied to them
<p>{{ user.firstName + ' ' + user.lastName }}</p>
<p>{{ getGreetingMessage() }}</p>
<p>{{ price * quantity }}</p>
---
Interpolation uses the “mustache” syntax, where expressions are enclosed in double curly braces:
<p>{{ expression }}</p>