'Angular, get component instance from inside a structural directive / from TemplateRef
I have a structural directive which conditionally renders a given template or not based on some conditions and it's used like:
<my-component *myMayBeShow>
The template is rendered by
const embeddedViewRef = this.viewContainer.createEmbeddedView(this.templateRef);
I can get the html nodes which were created:
embeddedViewRef.rootNodes[0]
But: how can i get the component instance "MyComponent" which were created by the embedded view? I need somethink like: https://angular.io/api/core/global/ngGetComponent but that utils are designed for debugging and are avaialble only in dev mode.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
