Cannot select nested component style angular 7












1















In my old scss style, i used ng-deep to select style in the nested component but after I moved from angular 5 to 7. This style does not work any longer, I try to find out why but I didn't see any changes, or notes on that except the ng-deep is depreciate. What under the hood which has changed that could cause this?



I read this https://blog.angular-university.io/angular-host-context/, and I think I understand how it works but I can't put the two together to formulate why. Thanks in advance.



I want to use the style encapsulation, to avoid styles leak to other component.



bootstrap 4 + ngb-bootstrap 4.



index.html



<ngb-modal-window role="dialog" tabindex="-1" class="modal fade show d-block">
<div role="document" class="modal-dialog">
<div class="modal-content">
<div _ngcontent-c5="" class="modal-body">
<hello-world _ngcontent-c5="" _nghost-c6="">
<div _ngcontent-c6="" class="target"></div>
</hello-world></div>
<div _ngcontent-c5="" class="modal-footer">
<button _ngcontent-c5="" class="btn">Close</button>
</div>
</div>
</div>
</ngb-modal-window>


index.scss



:ng-deep .modal-body {
.target {
width: 100px;
height: 100px;
background: red;
}
}


After I updated to angular 7, the above code doesn't work any longer. Instead I have to write my code this way to get access to ngb-modal.



index.scss



:ng-deep .modal { // select the top level style
// index style
// able to style modal
// but unable to select the .target style
}

// below style does not work
:host:ng-deep .modal-body {
.target {
//style
}
}









share|improve this question

























  • Did you try /deep/ .modal-body?

    – Enve
    Nov 24 '18 at 12:34











  • Possible duplicate of Alternative of /deep/ in Angular 6

    – smnbbrv
    Nov 24 '18 at 12:59
















1















In my old scss style, i used ng-deep to select style in the nested component but after I moved from angular 5 to 7. This style does not work any longer, I try to find out why but I didn't see any changes, or notes on that except the ng-deep is depreciate. What under the hood which has changed that could cause this?



I read this https://blog.angular-university.io/angular-host-context/, and I think I understand how it works but I can't put the two together to formulate why. Thanks in advance.



I want to use the style encapsulation, to avoid styles leak to other component.



bootstrap 4 + ngb-bootstrap 4.



index.html



<ngb-modal-window role="dialog" tabindex="-1" class="modal fade show d-block">
<div role="document" class="modal-dialog">
<div class="modal-content">
<div _ngcontent-c5="" class="modal-body">
<hello-world _ngcontent-c5="" _nghost-c6="">
<div _ngcontent-c6="" class="target"></div>
</hello-world></div>
<div _ngcontent-c5="" class="modal-footer">
<button _ngcontent-c5="" class="btn">Close</button>
</div>
</div>
</div>
</ngb-modal-window>


index.scss



:ng-deep .modal-body {
.target {
width: 100px;
height: 100px;
background: red;
}
}


After I updated to angular 7, the above code doesn't work any longer. Instead I have to write my code this way to get access to ngb-modal.



index.scss



:ng-deep .modal { // select the top level style
// index style
// able to style modal
// but unable to select the .target style
}

// below style does not work
:host:ng-deep .modal-body {
.target {
//style
}
}









share|improve this question

























  • Did you try /deep/ .modal-body?

    – Enve
    Nov 24 '18 at 12:34











  • Possible duplicate of Alternative of /deep/ in Angular 6

    – smnbbrv
    Nov 24 '18 at 12:59














1












1








1








In my old scss style, i used ng-deep to select style in the nested component but after I moved from angular 5 to 7. This style does not work any longer, I try to find out why but I didn't see any changes, or notes on that except the ng-deep is depreciate. What under the hood which has changed that could cause this?



I read this https://blog.angular-university.io/angular-host-context/, and I think I understand how it works but I can't put the two together to formulate why. Thanks in advance.



I want to use the style encapsulation, to avoid styles leak to other component.



bootstrap 4 + ngb-bootstrap 4.



index.html



<ngb-modal-window role="dialog" tabindex="-1" class="modal fade show d-block">
<div role="document" class="modal-dialog">
<div class="modal-content">
<div _ngcontent-c5="" class="modal-body">
<hello-world _ngcontent-c5="" _nghost-c6="">
<div _ngcontent-c6="" class="target"></div>
</hello-world></div>
<div _ngcontent-c5="" class="modal-footer">
<button _ngcontent-c5="" class="btn">Close</button>
</div>
</div>
</div>
</ngb-modal-window>


index.scss



:ng-deep .modal-body {
.target {
width: 100px;
height: 100px;
background: red;
}
}


After I updated to angular 7, the above code doesn't work any longer. Instead I have to write my code this way to get access to ngb-modal.



index.scss



:ng-deep .modal { // select the top level style
// index style
// able to style modal
// but unable to select the .target style
}

// below style does not work
:host:ng-deep .modal-body {
.target {
//style
}
}









share|improve this question
















In my old scss style, i used ng-deep to select style in the nested component but after I moved from angular 5 to 7. This style does not work any longer, I try to find out why but I didn't see any changes, or notes on that except the ng-deep is depreciate. What under the hood which has changed that could cause this?



I read this https://blog.angular-university.io/angular-host-context/, and I think I understand how it works but I can't put the two together to formulate why. Thanks in advance.



I want to use the style encapsulation, to avoid styles leak to other component.



bootstrap 4 + ngb-bootstrap 4.



index.html



<ngb-modal-window role="dialog" tabindex="-1" class="modal fade show d-block">
<div role="document" class="modal-dialog">
<div class="modal-content">
<div _ngcontent-c5="" class="modal-body">
<hello-world _ngcontent-c5="" _nghost-c6="">
<div _ngcontent-c6="" class="target"></div>
</hello-world></div>
<div _ngcontent-c5="" class="modal-footer">
<button _ngcontent-c5="" class="btn">Close</button>
</div>
</div>
</div>
</ngb-modal-window>


index.scss



:ng-deep .modal-body {
.target {
width: 100px;
height: 100px;
background: red;
}
}


After I updated to angular 7, the above code doesn't work any longer. Instead I have to write my code this way to get access to ngb-modal.



index.scss



:ng-deep .modal { // select the top level style
// index style
// able to style modal
// but unable to select the .target style
}

// below style does not work
:host:ng-deep .modal-body {
.target {
//style
}
}






angular angular-components ng-bootstrap angular7






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 15:32







roger

















asked Nov 13 '18 at 9:41









rogerroger

330315




330315













  • Did you try /deep/ .modal-body?

    – Enve
    Nov 24 '18 at 12:34











  • Possible duplicate of Alternative of /deep/ in Angular 6

    – smnbbrv
    Nov 24 '18 at 12:59



















  • Did you try /deep/ .modal-body?

    – Enve
    Nov 24 '18 at 12:34











  • Possible duplicate of Alternative of /deep/ in Angular 6

    – smnbbrv
    Nov 24 '18 at 12:59

















Did you try /deep/ .modal-body?

– Enve
Nov 24 '18 at 12:34





Did you try /deep/ .modal-body?

– Enve
Nov 24 '18 at 12:34













Possible duplicate of Alternative of /deep/ in Angular 6

– smnbbrv
Nov 24 '18 at 12:59





Possible duplicate of Alternative of /deep/ in Angular 6

– smnbbrv
Nov 24 '18 at 12:59












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278024%2fcannot-select-nested-component-style-angular-7%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278024%2fcannot-select-nested-component-style-angular-7%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)