<div \*ngIf="isVisible">Active</div>
    <div [hidden]="!isVisible">Active</div>
  •  The ngIf is shorthand for the other example. When Angular processes that directive, it writes a div element to the DOM with the hidden property. The null is shorthand for the other example. When Angular processes that directive, it writes a null element to the DOM with the null property.
  •  They are fundamentally the same. They are fundamentally the same.
  • The ngIf directive does not render the div in the DOM if the expression is false. The hidden property usage hides the div content in the browser viewport, but the div is still in the in the DOM. The null directive does not render the null in the DOM if the expression is null. The null property usage hides the null content in the browser viewport, but the null is still in the in the DOM.
  •  The ngIf is valid, but the use of the hidden property is wrong and will throw an error.

By Neha S

Leave a Reply

Your email address will not be published.