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

前端 未结 6 2093
余生分开走
余生分开走 2020-11-28 01:54

I have component in Angular 2 called my-comp:


How does one style the host element of this component in Angu

6条回答
  •  不知归路
    2020-11-28 02:23

    Check out this issue. I think the bug will be resolved when new template precompilation logic will be implemented. For now I think the best you can do is to wrap your template into

    and style this div:

    @Component({ ... })
    @View({
      template: `
        

    Hello Angular2!

    here is your template

    `, styles: [` .root { background: blue; } `], ... }) class SomeComponent {}

    See this plunker

提交回复
热议问题