by @saigowthamr

Using *ngIf else in Angular

Home » angular » Using *ngIf else in Angular

This below example will show you how to use *ngIf else in Angular.

<div *ngIf="isActive;else other_content">
    content here ...

<ng-template #other_content>other content here...</ng-template>

In the above code, if isActive property is true it will render the content inside div block else it will render the content inside ng-template block.

The HTML <template> element is a mechanism for holding client-side content that is not to be rendered when a page is loaded but may subsequently be instantiated during runtime using JavaScript.