Working with Angular 5, I am attempting to develop a dynamic component.
One of the components is a simple directive named MyColumnDef
(with the selector [myColumnDef]
). It is used in the following:
parent.compontent.html:
<div>
<my-table>
<ng-template myColumnDef>
Lorem ipsum.
</ng-template>
</my-table>
</div>
my-table.component.html:
<div>
Something:
<ng-container *ngTemplateOutlet="temp"></ng-container>
</div>
In my-table.component.ts:
@ContentChild(MyColumnDef, {read: TemplateRef}) temp;
The expected output should display the text 'Lorem ipsum.'
, however, the temp
variable is actually undefined
(as indicated by the console.log
in ngAfterViewInit
) and the reason for this remains unclear. Could there be something that I have overlooked?