Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using <ng-template>
<ng-template>
You will never see me :(
</ng-template>
<ng-template *ngIf="showContents">
You still won’t see me (even though I’m using a structural directive, there’s nothing that's telling Angular to use me)
</ng-template>
<ng-template *ngFor="let item of items">
No dice (same reason as *ngIf above)
</ng-template>
<div *ngIf="!showTemplate else template">
Hello
</div>
<ng-template #template>
Finally I am seen! (When showTemplate is true)
</ng-template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment