I have a question about adding styles to Angular components. e.g I would like to have every second angular component in a list to have red background-color. How can I make it happen?
I tried a lot of different things - it seems that it is added in HTML but doesn't work.
<ang-component class="someClass" />
<ang-component class="someClass" />
I tried setting it in parent component styles
ang-component:nth-child(odd) {
background-color: red;
}
but it doesn't work. It shows up while inspecting but there is no visible effect
EDIT: Code - to show an example how it looks
<form [formGroup]="form" class="someParentClass" (ngSubmit)="onUpdateForm()" >
<item></item>
<hr />
<item></item>
<item></item>
<hr />
<div id="btn-save-section">
<button class="cancel-btn" type="button">Cancel</button>
<button class="update-btn" type="button">Update</button>
</div>
I want item components to change - so every second should have background color red

component's selectorvia HTML adding a class to it. Instead you can achieve it by targetting the selecetor in a style's file. For example:ang-component {font-size: 1rem;}.ang-component:nth-child(odd): background-color: redright? It doesn't work for me