我写了一个组件命名my-component
并在里面添加了一些,并用这样的方式ng-template
命名每个组件:#
<my-component>
<ng-template #one>
1st format
</ng-template>
<ng-template #two>
2nd template
</ng-template>
<ng-template #three>
3rd template
</ng-template>
</my-component>
在声明时MyComponent
,我曾经@ContentChildren(TemplateRef)
访问过这三个模板。
现在我需要在内部以某种方式访问这些模板的名称(one
, two
, ),但我不知道如何。这是代码:示例代码three
MyComponent