The ng-template directive and ngIf

The ng-template directive allows us to run a set of HTML tag block based on ngIf|else condition. TemplateRef is the class name and <ng-template> is the html tag — they are both referencing the same thing.

We can use <ng-template> with ngFor, ngIf and ngSwitch. Using TemplateRef and ViewContainerRef we can reuse the code of
<ng-template> in our HTML template. <ng-template> example with ngFor is as follows.

<ng-template ngFor let-person [ngForOf]= "allPersons" let-i="index">
<p>{{i + 1}}. {{person.name}} : {{person.age}} </p>
</ng-template>

In Angular allow us to use ng-template with if/else scenario below example.

<div>
       <div *ngIf="photoID; then govId else newGovId" class="govID"></div>
        <ng-template #govId>
          <ion-item>
            <h2>Government Identity Card </h2>
              <img src={{photoID}}>
            <br/>
            <div class="gov-id">
              <label for="file">Edit Government ID</label>
              <input type="file" class="custom-file-input" (change)="detectGovtIdFile($event)">
            </div>
          </ion-item>
        </ng-template>
        <ng-template #newGovId>
          <ion-item>
            <input type="file" class="custom-file-input" (change)="detectGovetIdFile($event)">
          </ion-item>
        </ng-template>
 </div>

A simpler version of ngIf and else template

We can used platform variable of Platform services directly into template. To check if plaftform is android or not.
<div ngIf= "platform.is('android'); then truecondition else falseCondition">
or 
<div *ngIf="searchResults;  else elseBlock">

</div> // End of true Condition
<ng-template #elseBlock>

</ng-template>