Angular string interpolation

js:


this.user = { email: 'info@site.com' }

html:


email: {{ user?.email || 'N/A'}}

name: {{ user?.name || 'N/A'}}

Basic math operations:

html:


{{1 + 1}}

Template reference variable

html:


<input #userInput />

{{userInput.value}}

Property binding

js:


imageUrl = '../assets/phone.png';

isDisabled = true;

html:


<img [src]="imageUrl">

<button [disabled]="isDisabled">Button</button>

<div [hidden]="isDisabled">

  Hidden block.

</div>

Leave a Comment