Angular 10 NgIf Directive
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.
NgModule: Module used by NgIf is:
- 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.