ngIf is the directive. Because it’s a structural directive (template-based), you need to use the * prefix to use it into templates.

*ngIf corresponds to the shortcut for the following syntax (“syntactic sugar”):

  1. <template [ngIf]="condition">
  2. <p>
  3. Our heroes are true!
  4. </p>
  5. </template>

Equivalent to:

  1. <p *ngIf="condition">
  2. Our heroes are true!
  3. </p>