I'm trying to access a template reference within some nested structural directives:
<ng-container [ngSwitch]="currentIndex">
<ng-container *ngFor="let panel of panels; index as panelIndex;">
<ng-container *ngSwitchCase="panelIndex">
<ng-container #visiblePanel *ngComponentOutlet="panel; injector: injector"></ng-container>
</ng-container>
</ng-container>
</ng-container>
I try to reference the component with:
@ViewChild('visiblePanel') currentPanel: WizardPanelComponent;
I've also tried id
and Component
selectors. Basically, it's always undefined:
// Button press
onNext() {
this.data = this.currentPanel.data; // this.currentPanel is undefined
...
}
Is there some way to get a reference in ts to the currently switched component?