FrontendDeveloper.in

Angular question detail

What is the purpose of `*ngIf` directive?

Sometimes an app needs to display a view or a portion of a view only under specific circumstances. The Angular *ngIf directive inserts or removes an element based on a truthy/falsy condition. Let's take an example to display a message if the user age is more than 18:

Note: Angular isn't showing and hiding the message. It is adding and removing the paragraph element from the DOM. That improves performance, especially in the larger projects with many data bindings.

Back to all Angular questions
Get LinkedIn Premium at Rs 399