0Pricing
Angular Academy · Lesson

TemplateRef and ViewContainerRef

Render templates dynamically.

Imperative Rendering

Sometimes you must render content programmatically rather than declaratively. Angular exposes TemplateRef and ViewContainerRef for this low-level control.

TemplateRef

A TemplateRef is a handle to an <ng-template>. It represents markup you can instantiate later.

tpl = viewChild.required<TemplateRef<unknown>>('tpl');

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