Skip to content

Instantly share code, notes, and snippets.

@ericjeker
Last active March 13, 2020 06:38
Show Gist options
  • Save ericjeker/18bb6e3a3c3cec0f6387798b31fe715d to your computer and use it in GitHub Desktop.
Save ericjeker/18bb6e3a3c3cec0f6387798b31fe715d to your computer and use it in GitHub Desktop.
Simple TemplateRef and ngTemplateOutlet usage in Angular
<app-my-content tplRef="myContent"></app-my-content>
<ng-template #myContent>
<app-my-other-component>Hello world!</app-my-other-component>
</ng-template>
@Component({
selector: 'app-my-content',
template: '<ng-container *ngTemplateOutlet="tplRef"></ng-container>',
})
class MyContent {
@Input() tplRef: TemplateRef<any>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment