Emmanuel Villegas
Emmanuel Villegas

Reputation: 1514

how to target component styles from host component angular 2

I have this :

@Component({
    selector: 'host-element',
    template: `<elementA></elementA>`,
    styles:[''] //styles here
})

export class hostElement {}

How do I target the styles of elementA component from host-element?

Thanks in advance!!

Upvotes: 5

Views: 6706

Answers (2)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657268

:host elementA {
  // style here
}

Upvotes: 10

Meir
Meir

Reputation: 14375

Angular has a special css operator /deep/, you can read about it here.

To make a style go beyond your component, put in your css (sass, less):

/deep/ .elemet-a-class {
   ... your style;
}

Or if you want to put it locally, just

styles: ['/deep/ .element-a-class { ... }']

Upvotes: 4

Related Questions