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
- Single-Slot Content Projection
- Multi-Slot Projection with select
- ng-template and ng-container
- TemplateRef and ViewContainerRef