Angular 22 · Components and templates

Show content conditionally

Use the built-in @if block instead of *ngIf.

@if (user) {
  <p>Hello, {{ user.name }}</p>
} @else {
  <p>Please sign in.</p>
}

Official Angular 22 documentation

More components and templates commands

All components and templates commands · Angular 22 cheatsheet

Was this page helpful?