⊗jsagPmCdIC 23 of 97 menu

The if construct in Angular

Condition in Angular can also be done using a special construction @if. This construction allows you to show or hide code blocks by condition. Let's see how to work with it.

Let us have the following variable:

export class AppComponent { public isAdmin: boolean = true; }

Let's make a div that will be shown if this variable has a value of true:

@if (isAdmin) { <div> text </div> }

Let's make it so that the div is shown if our variable has a value of false:

@if (!isAdmin) { <div> text </div> }

Make the property isAdult. Show the adult text if our variable contains the value true.

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