Skip to content

Instantly share code, notes, and snippets.

@armanozak
Created November 5, 2019 11:16
Show Gist options
  • Save armanozak/f48fb328a98791b1e4977a4e8a278be0 to your computer and use it in GitHub Desktop.
Save armanozak/f48fb328a98791b1e4977a4e8a278be0 to your computer and use it in GitHub Desktop.
Adaptive Components - Using :host-context Selector to Set a Style Based on Context #blog
import { ChangeDetectionStrategy, Component } from '@angular/core';
@Component({
selector: 'app-card-title',
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<h5 class="card-title">
<ng-content></ng-content>
</h5>
`,
styles: [
`
:host-context(app-card-horizontal) h5 {
border-bottom: 1px solid #eee;
}
`,
],
})
export class CardTitleComponent {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment