css - Angular 2: How to style host element of the component? -


i have component in angular 2 called my-comp:

<my-comp></my-comp> 

how 1 style host element of component in angular 2?

in polymer, use ":host" selector. tried in angular 2. doesn't work.

:host {   display: block;   width: 100%;   height: 100%; } 

i tried using component selector:

my-comp {   display: block;   width: 100%;   height: 100%; } 

both approaches don't seem work.

thanks.

there bug, fixed in meantime. :host { } works fine now.

also supported are

  • :host(selector) { ... } selector match attributes, classes, ... on host element
  • :host-context(selector) { ... } selector match elements, classes, ...on parent components

  • selector /deep/ selector (alias selector >>> selector doesn't work sass) styles match across element boundaries

    • update: sass deprecating /deep/.
      angular (ts , dart) added ::ng-deep replacement that's compatible sass.

see load external css style angular 2 component

/deep/ , >>> not affected same selector combinators in chrome deprecated.
angular emulates (rewrites) them, , therefore doesn't depend on browsers supporting them.

this why /deep/ , >>> don't work viewencapsulation.native enables native shadow dom , depends on browser support.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -