Lesson 5 / 32

Interpolation & Property Binding

Show component data in templates with interpolation and bind DOM properties with square brackets.

Interpolation

{{ expression }} inserts a value as text inside the template.

<h1>{{ title }}</h1>
<p>Total: {{ price * quantity }}</p>

Property binding

[property]="expression" binds a DOM property (not just text) to a class value.

<img [src]="photoUrl" [alt]="photoAlt">
<button [disabled]="isSaving">Save</button>

One-way, class to view

Both are one-way: data flows from the component class to the template. Change the class field and the view updates automatically.