2

I've done some research without any success to find a way to pass a TemplateRef from a grand parent component to a child component.

Example :

grand-parent-component

<div>
    <parent-component>
        <ng-template #contentTemplate let-value="myvalue">
        </ng-template>
    </parent-component>
</div>

parent-component

<div>
    <!-- pass here somehow the template from the parent to the child -->
    <child-component></child-component>
</div>

child-component

<div>
    <ng-template *ngTemplateOutlet="contentTemplate; context: {value: myValue}">
    </ng-template>
</div>

export class ChildComponent {
    @ContentChild('contentTemplate') contentTemplate
}

I would like my child component to display the template given by my grand-parent-component.

How I am supposed to do that?

0 Answers0