Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度5-从父级到子级传递模板_Angular_Templates_Components_Angular5_Parent Child - Fatal编程技术网

Angular 角度5-从父级到子级传递模板

Angular 角度5-从父级到子级传递模板,angular,templates,components,angular5,parent-child,Angular,Templates,Components,Angular5,Parent Child,我做了一些研究,但没有找到将TemplateRef从父组件传递到子组件的方法 例如: 总父级组件 <div> <parent-component> <ng-template #contentTemplate let-value="myvalue"> </ng-template> </parent-component> </div> <div> <ng

我做了一些研究,但没有找到将TemplateRef从父组件传递到子组件的方法

例如:

总父级组件

<div>
    <parent-component>
        <ng-template #contentTemplate let-value="myvalue">
        </ng-template>
    </parent-component>
</div>
<div>
    <ng-template *ngTemplateOutlet="contentTemplate; context: {value: myValue}">
    </ng-template>
</div>

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

父组件

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

子组件

<div>
    <parent-component>
        <ng-template #contentTemplate let-value="myvalue">
        </ng-template>
    </parent-component>
</div>
<div>
    <ng-template *ngTemplateOutlet="contentTemplate; context: {value: myValue}">
    </ng-template>
</div>

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

导出类子组件{
@ContentChild('contentTemplate')contentTemplate
}
我希望我的子组件显示我的父组件提供的模板

我该怎么做