Angular: getting started

Lesson 04 · 10 min

@if and @for

A piece of the template is either there or not. A list is @for with track by id.

10 minLesson 4 of 8Practice includedAsk AI on any point

In new templates: @if (user) { … } @else { … } and @for (item of items; track item.id) { … }. The old *ngIf / *ngFor are still around. track is like key in React: without a stable id the list "drifts" on insertion.

Sign in to continue

The rest of this lesson opens after sign up

The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.