0Pricing
Angular Academy · Lesson

ng-template and ng-container

Define and host template fragments.

Templates That Do Not Render

<ng-template> defines a chunk of markup that is not rendered until something explicitly instantiates it. It is the foundation of structural directives like *ngIf.

Defining a Template

Content inside <ng-template> stays inert. You give it a reference variable to use it elsewhere.

<ng-template #empty>
  <p>No items found.</p>
</ng-template>

All lessons in this course

  1. Single-Slot Content Projection
  2. Multi-Slot Projection with select
  3. ng-template and ng-container
  4. TemplateRef and ViewContainerRef
← Back to Angular Academy