The way I see it, it could be used as a replacement for <div>
containers for styling a component. Example:
Using container
@Component({
template: `
<div class="container">
<h1>Some Title</h1>
<p>Some Content</h1>
</div>
`,
styles: [`
.container {
border: 1px solid black;
display: flex;
}
`],
})
Using :host
@Component({
template: `
<h1>Some Title</h1>
<p>Some Content</h1>
`,
styles: [`
:host {
border: 1px solid black;
display: flex;
}
`],
})
If I understand correctly, these two solve the exact same problem. And it's nice to have one less element and class to worry about in pretty much every single component.
Questions: Is this what :host
is intended for? If not, what is the point of it, and what are the best practices for giving style to your component aside from adding containers everywhere?