In this post, we will learn about ng if else condition in angular with example
NgIf
the directive will be used to display DOM based on a condition. It is very useful to show or hide a HTML div
Sample Code
In the above example, we declared a boolean variable called as show. We are changing that boolean value to true on ngOnInit method
In the html file we are using that show boolean variable to display the paragraph tag
if the show boolean is false then the html div will not display
ngIf else Example
We need to define the else block inside a ng-template block. below is the example for ng if else condition
Conclusion
In the above post, we learned about ngIf else condition in angular with example