I have the following component structure:
in app.component.html
:
<placeholder *ngFor="...">
<visual-comp [id]="..."></visual-comp>
</placeholder>
in placeholder.component.html
:
<renderer>
<ng-content></ng-content>
</renderer>
in renderer.component.html
:
<ng-content></ng-content>
The problem is the following, when I'm trying to access <visual-comp ...></visual-comp>
projected inside the rederer
component, using @ContentChild
, I'm getting undefined
, while in placeholder.component.ts
I can access it.
So here's pat of my renderer.component.ts
:
@Component(...)
export class RendererComponent implements AfterContentInit {
@ContentChild(VisualCompComponent) public _visualCmp!: VisualCompComponent;
ngAfterContentInit(): void {
console.log('Visual Component', this._visualCmp); // Outputs: Visual Component undefined
}
}
Any ideas?