Angular › Components & Templates

What is Angular's template syntax used for displaying dynamic values on the page?

Beginner

Answer

You use double curly braces, called interpolation, to display the value of a property directly inside your HTML template. Angular automatically keeps this displayed value in sync whenever the underlying property changes.
@Component({
  selector: 'app-price',
  template: `<p>Total: {{ price * quantity }}</p>`
})
export class PriceComponent {
  price = 10;
  quantity = 3;
}
Real-world example A shopping cart component uses interpolation to calculate and display the total price of an item directly inside the template, updating automatically whenever the quantity changes.

Common follow-ups: Can you call a function inside interpolation, not just a simple property?;What happens if the value inside interpolation is null or undefined?