| Angular-JIT-vs-AOT | Front end Technologies | |
Angular Interpolation |
Interpolation in Angular is a way to bind data from the component class to the view (template).
It uses double curly braces {{ }} to display dynamic values in HTML.
Example:
<h1>{{ '{{ title }}' }}</h1>
If title = "Welcome" in your component, the view will render: Welcome
You can use simple operations like:
<p>{{ '{{ 5 + 3 }}' }}</p> <!-- Outputs: 8 -->
<p>{{ '{{ user.name.toUpperCase() }}' }}</p>
It only works with property values, not HTML attributes like href, src, etc.
{{ expression }}{{ }}.Component (TypeScript):
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
title = 'Angular Interpolation Example';
user = 'John';
num1 = 10;
num2 = 20;
getGreeting() {
return "Hello " + this.user + "!";
}
}
Template (HTML):
<h1>{{ title }}</h1>
<p> User: {{ user }} </p1>
<p>Sum: {{ num1 + num2 }}</p1>
<p>{{ getGreeting() }}</p1>
Angular Interpolation Example
User: John
Sum: 30
Hello John!
{{ }}.[property]="value") when working with DOM attributes.
💡 Tip: Interpolation is one-way binding (from component → view).
If you need two-way binding, use [(ngModel)].
| Angular-JIT-vs-AOT | Front end Technologies | |