Pranam Bhat
What is the difference between ngIf and *ngIf in Angular?

What is the difference between ngIf and *ngIf in Angular?

By Pranam Bhat in Angular on Aug 13 2021
  • Bohdan Stupak
    Oct, 2021 12

    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>

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS