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.
In Angular allow us to use ng-template with if/else scenario below example.
A simpler version of ngIf and else template