1

I have the following angular component

@Component({ selector: 'app-bar', templateUrl: './bar.component.html', styleUrls: ['./bar.component.scss'], encapsulation: ViewEncapsulation.ShadowDom, changeDetection: ChangeDetectionStrategy.OnPush }) export class BarComponent { @Input() @HostBinding('class') cls; } 

So I thought, if I set cls to 'hide-me' I hide it. I added the following to bar.component.scss:

:host { &.hide-me { display: none; } } 

DEMO

This doesn't do anything and it has to do with the shadow dom encapsulation. If you remove that line it works again as expected. Any suggestions why this doesn't work anymore with shadowDom? and is there a way to fix this with shadow dom enabled of course ;)

1 Answer 1

4

Changing your scss to look like this should work

:host(.hide-me) { display: none; } 

Refer to this question for more info

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.