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
- Write a standalone component
- Pass data in and out
- Loop over items
- Handle an event
- Bind a property
- Toggle a CSS class
All components and templates commands · Angular 22 cheatsheet