I have a method in my angular application that creates a component and inserts it into a parent element via a ComponentFactory (the method does some more stuff later, but that should not matter). My problem is, that the generated component nodes don't have any _ngcontent-cXXX attributes. Hence, the style encapsulation prevents the created components from inheriting any styles from their parents. With non-dynamic components, it works just fine.
Of course I could get the _nghost-XXX attribute of the parent element via DOM access and simply append the number myself, but that is not very clean. Is there a better way to do it?
Here is the line of code responsible for creating and inserting the component:
const child= hostComponent.createComponent(factory);
Here is some CSS that should work (host.component.scss):
.app-child { color: red; }
I am using classes as component selectors, if that matters.
If you need more code or information, let me know :)