How and where to use ::ng-deep?

Jeyabalan Thavamani picture Jeyabalan Thavamani · Oct 17, 2017 · Viewed 159.7k times · Source

I'm new to Angular 4, so could anyone please explain how and where to use ::ng-deep in Angular 4?

Actually I want to overwrite some of the CSS properties of the child components from the parent components. Moreover is it supported on IE11?

Thanks for the help.

Answer

Sajeetharan picture Sajeetharan · Oct 17, 2017

Usually /deep/ “shadow-piercing” combinator can be used to force a style down to child components. This selector had an alias >>> and now has another one called ::ng-deep.

since /deep/ combinator has been deprecated, it is recommended to use ::ng-deep

For example:

<div class="overview tab-pane" id="overview" role="tabpanel" [innerHTML]="project?.getContent( 'DETAILS')"></div>

and css

.overview {
    ::ng-deep {
        p {
            &:last-child {
                margin-bottom: 0;
            }
        }
    }
}

it will be applied to child components