There are three structural directives in angular
*ngIf
[ngSwtich]
*ngFor
1. *ngIf (with else) use to hide/show element using like if-else condition as shown below
In below example we add else condition in ngIf block and then use ng-template to display else condition
import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-test', template: ` <h1> Welcome {{name}} </h1> <h2> myStatus variable value is {{myStatus}} </h2> <h3 *ngIf="myStatus ; else myElseBlock"> this is if block</h3> <ng-template #myElseBlock> <h3> this is Else block</h3> <ng-template> `, styles: [` `] }) export class TestComponent implements OnInit { public name = "Amey Raut"; public myStatus = false; constructor() { } ngOnInit() { } }