Problem Statement
Explain Angular’s view encapsulation modes and when to use each.
Explanation
Emulated (default) scopes styles to the component by adding unique attributes—good balance of isolation and compatibility. ShadowDom uses native shadow root for stronger isolation; great for design systems. None applies styles globally—use sparingly for global themes or legacy overrides.
Code Solution
SolutionRead Only
@Component({ selector:'x', template:'…', styles:[`:host{display:block}`], encapsulation: ViewEncapsulation.Emulated })