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) { ... }- selectormatch attributes, classes, ... on host element
- :host-context(selector) { ... }- selectormatch elements, classes, ...on parent components
- selector /deep/ selector(alias- selector >>> selectordoesn't work sass) styles match across element boundaries- update: sass deprecating /deep/.
 angular (ts , dart) added::ng-deepreplacement that's compatible sass.
 
- update: sass deprecating 
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
Post a Comment