Ad Code

Responsive Advertisement

What is ::ng-deep selector in angular?

What is ::ng-deep selector in angular? 

Component styles normally apply only to the HTML in the component's own template.

Use the ::ng-deep shadow-piercing descendant combinator to force a style down through the child component tree into all the child component views. The ::ng-deep combinator works to any depth of nested components, and it applies to both the view children and content children of the component.    

The following example targets all <h3> elements, from the host element down through this component to all of its child elements in the DOM.
Code:
parent.component.html
Parent content.

<app-child></app-child>
parent.component.css
::ng-deep h3 {
  font-style: italic;
}
child.component.html
<h3>Child title</h3>
Child content.
Result:
Parent content.

Child title

Child content.
Reactions

Post a Comment

0 Comments