I checked: ViewChildren for ng-template and Access multiple viewchildren using @viewchild
But I am not able to call my template via the value of a variable...
So my template is like this:
<ng-container *ngFor="let feature of Object.values(features)">
<ng-container *ngTemplateOutlet="templates[feature]"></ng-container>
</ng-container>
<ng-template #myFeature>
Nothing to see here
</ng-template>
<ng-template #myOtherFeature>
Nothing to see here
</ng-template>
features
is an enum with matching values to my templates names... then in my class, I tried to grab all the ViewChildren
like this:
export class SomeClass {
@ViewChildren(TemplateRef) templates: QueryList<TemplateRef<any>>;
}
So the idea is that, i thought I should be able to reference the correct template by doing templates[feature]
which should yield something like templates['myFeature']
and give me the right template... but is not.
How do I archive this?