如何从主机组件角度2中定位组件样式

时间:2016-11-02 15:18:59

标签: angular

我有这个:

foreach (var category in jsonObj.categories)
{
    <p> <strong> @category.name </strong> </p>

    foreach (var subcategory in category.subcategories) // <= here is the key.
    {
         <p> <strong> @subcategory.name </strong> </p>
    }
}

如何定位@Component({ selector: 'host-element', template: `<elementA></elementA>`, styles:[''] //styles here }) export class hostElement {} 的{​​{1}}组件的样式?

提前致谢!!

2 个答案:

答案 0 :(得分:4)

Angular有一个特殊的css操作符/deep/,你可以阅读it here

要使一个样式超出你的组件,请加入你的css(sass,less):

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

或者如果你想把它放在本地,只需

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

答案 1 :(得分:4)

:host elementA {
  // style here
}