Musím prepísať štýly komponentov zvonku v uhlovom smere5. Skúsil som kód uvedený nižšie a nefunguje to.
V tomto projekte je predvolená viewEncapsulation, tj Emulated.
app.component.html
<app-vivek-button class="testClass">Primary</app-vivek-button>
app.component.css
::ng-deep app-vivek-button.testClass {
background-color: tomato !important;
color: teal;
}
vivek-button.component.html
<button class="button-style">
<ng-content></ng-content>
</button>
vivek-button.component.css
:host{
display: block;
}
.button-style {
min-width: 200px;
background-color: rgb(60, 114, 230);
color:#fff;
height: 32px;
border: none;
}
Snažil sa sledovať všetky spôsoby uvedené v tomto dokumente tiež otázka
odpovede:
0 pre odpoveď č. 1Skúste vložiť požadovaný vad style.css
čo je globálne pre aplikáciu.
app-vivek-button.testClass {
background-color: tomato !important;
color: teal;
}