我有这个模板
<ng-container #gridView>
<ng-template #col1 let-row="row" let-column="column" colName="'abc'" colValue="'tableValue'" colWidth="'70px'" colEditable="'false'" colVisible="'true'">
test1 cell {{row[column.value]}}
</ng-template>
<ng-template #col_2 let-row="row" let-column="column" colName="'edf'" colValue="'tableValue2'" colWidth="'150px'" colEditable="'false'" colVisible="'true'">
test1 cell {{row[column.value]}}
</ng-template>
</ng-container>
<my-grid #grid></my-grid >
我希望能够为容器中的每个模板(#col1,#col2,ect)获取TemplateRef。
我已经能够使用ViewChild获取单个TemplateRef
@ViewChild('col1') public col1: TemplateRef<any>
但我想要的是能够获得TemplateRef的集合。
我尝试使用viewChildren
@ViewChildren('gridView') gridTemplates: any;
这给了我一个长度为1的结果,当我期望一个包含两个成员的结果数组时。 nativeEelement是一个注释(这不是意料之外的,但也没有用)。如何从QueryList获取TemplateRefs?
另外,如何获取我附加到模板的属性?
我尝试使用指令作为选择器创建属性指令并使用ContentChildren和ViewChildren,但没有成功。