29 of 97 menu

Syntactic Sugar in Angular Terms

The *ngIf directive is actually syntactic sugar (i.e. a simplification of the syntax for convenience). Let's see what this means. Let's say we have the following code:

<div *ngIf="isAdmin"> text </div>

In fact, technically it will look like this:

<ng-template [ngIf]="isAdmin"> <div> text </div> </ng-template>

Let the property age store the user's age. Show adult text if the user's age is greater than 18 years old, and child text otherwise.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline