Is there a way to override the effects of ViewEncapsulation.None? For example, I have a component called "firstComponent" that defines a CSS class with certain properties. Another component, "secondComponent," uses the same CSS class. However, I want "secondComponent" to apply different specific values for the properties defined in the stylesheet of the first component. How can I achieve this?
Please note: I tried redefining the class in "secondComponent" with different values while keeping the viewEncapsulation of secondComponent as default, but it did not work for me.
FirstComponent:
@Component({
moduleId: module.id,
selector: "FirstComponent",
templateUrl: 'FirstComponent.component.html',
styleUrls: ['FirstComponent.component.css'],
encapsulation: ViewEncapsulation.None
})
FirstComponent.component.css
.ui-tree .ui-tree-container {
background-color: #252525;
color: white;
}
Second Component:
@Component({
moduleId: module.id,
selector: "SecondComponent",
templateUrl: 'SecondComponent.component.html',
styleUrls: ['SecondComponent.component.css'],
})
SecondComponent.Component.css
.ui-tree .ui-tree-container {
background-color: white;
color: black;
}
In both components, I am creating p-tree which internally utilizes .ui-tree-container. In my secondComponent, I want the tree's background to be white while in all other instances, the tree's background should remain black.