Angular 10 NgIf Directive Last Updated : 03 Jun, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we are going to see what is NgIf in Angular 10 and how to use it. The ngIf Directive in Angular10 is used to remove or recreate a portion of HTML element based on an expression. If the expression inside it is false then the element is removed and if it is true then the element is added to the DOM. Syntax: <li *ngIf='condition'></li> NgModule: Module used by NgIf is: CommonModule Selectors: [ngIf] Approach: Create an Angular app to be used.There is no need for any import for the NgIf to be used.In app.component.ts define the variable for which condition is to be checked with ngIf directive.In app.component.html use NgIf directive with conditions to be checked.Serve the angular app using ng serve to see the output. Example 1: app.component.ts import { Component, Inject } from '@angular/core'; import { PLATFORM_ID } from '@angular/core'; import { isPlatformWorkerApp } from '@angular/common'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: [ './app.component.css' ] }) export class AppComponent { myBool = true; } app.component.html <div *ngIf = 'myBool'>Boolean is set to true</div> Output: Example 2: JavaScript import { Component, Inject } from '@angular/core'; import { PLATFORM_ID } from '@angular/core'; import { isPlatformWorkerApp } from '@angular/common'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: [ './app.component.css' ] }) export class AppComponent { variab = 10; } app.component.html <div *ngIf = 'variab==1; else multi'>{{variab}}</div> <ng-template #multi> {{variab *2}} </ng-template> Output: Reference: https://angular.io/api/common/NgIf Comment More infoAdvertise with us Next Article Angular 10 NgIf Directive T taran910 Follow Improve Article Tags : Web Technologies AngularJS AngularJS-Directives Angular10 Similar Reads Angular 10 NgPlural Directive In this article, we are going to see what is NgPlural in Angular 10 and how to use it. The NgPlural in Angular10 is used to Add or remove DOM sub-trees based on a numeric value. Syntax: <li *NgPlural='condition'></li> NgModule: Module used by NgPlural is: CommonModule  Selectors: [NgPlu 1 min read Angular10 NgFor Directive In this article, we are going to see what is NgFor in Angular 10 and how to use it. NgFor is used as a structural directive that renders each element for the given collection each element can be displayed on the page. Syntax: <li *ngFor='condition'></li> NgModule: Module used by NgForOf 1 min read AngularJS ng-if Directive The ng-if Directive in AngularJS is used to remove or recreate a portion of the HTML element based on an expression. The ng-if is different from the ng-hide directive because it completely removes the element in the DOM rather than just hiding the display of the element. If the expression inside it 2 min read Angular 7 | Directives Directives in Angular 7 are Typescript class which is declared with decorator @Directive. These are the Document Object Model (DOM) instruction sets, which decide how logic implementation can be done.Angular directives can be classified into three types:  Component Directives: It forms the main cla 2 min read Angular10 NgSwitch Directive In this article, we are going to see what is NgSwitch in Angular 10 and how to use it. The NgSwitch in Angular10 is used to specify the condition to show or hide the child elements. Syntax: <li *NgSwitch='condition'></li> NgModule: Module used by NgSwitch is: CommonModule  Selectors: [N 1 min read Like