CodeZettaInterview Hub

Angular · Templates · Fresh / Intern · Comparison

What is the difference between *ngIf and @if in Angular templates?

Short Interview Answer

@if is the built-in control flow; *ngIf is the structural directive from CommonModule.

Detailed Explanation

Built-in @if/@for/@switch are preferred in modern Angular: better type narrowing, no NgIf import, and clearer syntax. *ngIf still works for older codebases.

Did you know this answer?