# @if

*noun*

say it: **“AT IF”** **/æt ɪf/**

Angular template syntax, @if, that shows a block only when a condition is true.

## What does `@if` do?

`@if` shows a block of the template only when a condition is true. Add `@else` for the other case. It replaced the older `*ngIf`.

```html
@if (user) {
  <p>Welcome, {{ user.name }}</p>
} @else {
  <a routerLink="/login">Log in</a>
}
```

## In a sentence

- “**@if** (cart.length === 0) shows "Your cart is empty".”

Level: Apprentice · [More Angular terms at this level](https://www.ask-codey.com/glossary?category=angular&level=2)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/if
