What is ViewEncapsulation?
Model answer
It controls how a component's styles apply. The default, Emulated, makes styles apply only to that component's template by adding special attributes, so styles do not leak out and global styles still apply in. None makes the styles global. ShadowDom uses the browser's native shadow DOM for real isolation.
Most apps keep Emulated. To style a child component from outside, prefer inputs or CSS variables over breaking encapsulation.
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.
More questions
- What are the parts of a component?
- What is data binding? Explain the four types.
- What is the difference between interpolation and property binding?
- How do you pass data from a parent component to a child component?
- How does a child component send data to its parent?
- What is the component lifecycle? Describe the main hooks.