Angular2 styling issues caused by DOM attributes _ngcontent-* vs. _nghost-*

前端 未结 3 1462
一整个雨季
一整个雨季 2020-12-24 07:46

I have an issue with scss and the cli: angular adds an attribute _nghost-fyw-1 to the apps tag (component) during runtime. at the same time it adds an attribute

3条回答
  •  星月不相逢
    2020-12-24 08:02

    ::ng-deep works for me, adding into app.component.scss:

    :host ::ng-deep .mat-card {
        background: #000 !important;
        color: #fff;
    }
    

    The documentation (https://angular.io/guide/component-styles) says:

    The shadow-piercing descendant combinator is deprecated and support is being removed from major browsers and tools. As such we plan to drop support in Angular (for all 3 of /deep/, >>> and ::ng-deep). Until then ::ng-deep should be preferred for a broader compatibility with the tools.

    Use it, with precaution...

提交回复
热议问题