What is the equivalent of ngShow and ngHide in Angular 2

To get the equivalent of ngShow in angular 2+ you have the hidden property which can be used, you may make use of hidden property and pass your variable name which is bool type other than this you could also make use of ngif

[hidden]="!yourVariable"

*ngIf="yourVariable"

What is the equivalent of ngShow and ngHide in Angular 2+

With these two ways you can either show or hide the things in angular 2+ and as we all know that ngIf would remove the element from the DOM where as hidden would just hide this using css. so according to your need you can choose either of them

CP Variyani

http://codingfriday.com

He is a Full Stack Web Developer with almost 8 years of professional experience. Learn more and connect with him on Facebook, Instagram, LinkedIn.

Scroll to Top