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.