1

I have a component inside the component I declared ng-content so afther that i want to add styles to these components which will be inside the ng-content example bellow

Parent component

<ng-content></ng-content>

now i use the parent component and give some content into the selectors

<app-parent-component>
  <div class="block"></div>
</app-parent-component>

so in the DOM I have this result
<app-parent-component>

<div class="block"></div>

<app-parent-component>

How can I add class to the block div from parent component?

Sergio
  • 35
  • 5

1 Answers1

1

I found the solution look bellow

parent component html

<ng-content></ng-content>

parent component style scss

::ng-deep .block{
  background-color: red;
  width: 100px;
  height: 100px;
}

child component html

<app-parent-component>
  <div class="block"></div>
</app-parent-component>
Sergio
  • 35
  • 5