Angular 打印角度为6的嵌套ng模板

Angular 打印角度为6的嵌套ng模板,angular,typescript,angular6,Angular,Typescript,Angular6,我有如下模板 <ng-template #parent> <ng-template #child1> child 1 </ng-template> <ng-template #child2> child 2 </ng-template> </ng-template> 儿童1 儿童2 只想使用#parent打印#child 1和#child 2 有什么想法吗

我有如下模板

<ng-template #parent>
    <ng-template #child1>
        child 1
    </ng-template>
    <ng-template #child2>
        child 2
    </ng-template>
</ng-template>

儿童1
儿童2
只想使用#parent打印#child 1和#child 2 有什么想法吗?

parent.component.html

<div class="container">
  <h1> Parent component </h1>
  <ng-content></ng-content>
</div>
<h2> Child Component </h2>
<parent-component>
  <child-component></child-component>
</parent-component>

父组件
child.component.html

<div class="container">
  <h1> Parent component </h1>
  <ng-content></ng-content>
</div>
<h2> Child Component </h2>
<parent-component>
  <child-component></child-component>
</parent-component>
子组件
app.component.html

<div class="container">
  <h1> Parent component </h1>
  <ng-content></ng-content>
</div>
<h2> Child Component </h2>
<parent-component>
  <child-component></child-component>
</parent-component>

呈现为:

<div class="container">
  <h1> Parent component </h1>
  <h2> Child component </h2>
</div>

父组件
子组件

也许使用
ng容器
会有所帮助,它不会在DOM中呈现,但您可以在其上使用模板指令:@undefinedMayNotBeNull我使用的
ngTemplateOutlet
相对较新,而且可能无法传递@Inputs您将从父级传递到子级的哪些数据?@undefinedMayNotBeNull我正在尝试使用@ContentChildren打印子级,但显示“templateRef.createEmbeddedView不是函数”错误