Let's say I have a simple Angular component here called MyComponent.
import { Component, ViewEncapsulation } from '@angular/core';
@Component({
selector: '[my-component]',
template: `
<div class="my-component-child">
<ng-content></ng-content>
</div>`,
encapsulation: ViewEncapsulation.None,
host: { 'class': 'my-component' }
})
export class MyComponent {
constructor() { }
}
This component is then used inside ParentComponent.
Because MyComponent encapsulation is set to none, I can style its .my-component class from within ParentComponent but I cannot style .my-component-child unless I set ParentComponent encapsulation to none, which I prefer to avoid.
How can I style .my-component-child or workaround it (without using root styles.scss or ::ng-deep or parent's encapsulation set to none)?
If it's not possible to do the above with those conditions, are there any Angular practices or strategies that deal with this kind of situation (I'm still fairly new to Angular)?