子组件 index.component.ts
<div>
我是带颜色的文字
</div>
父组件
.red {
color: red;
}
<!--给子元素加上类名red-->
<app-index [class.red] = true></app-index>
运行后的效果
子组件 index.component.ts
<div>
我是带颜色的文字
</div>
父组件
.red {
color: red;
}
<!--给子元素加上类名red-->
<app-index [class.red] = true></app-index>
运行后的效果