如何使用Ang-Material-2的mat-slide-toggle更改文本样式?
<mat-slide-toggle [color]="primary" [checked]="true">Slide me</mat-slide-toggle>
<h3>Text</h3>
答案 0 :(得分:1)
根据切换状态将类或样式属性绑定到<h3>
元素:
<mat-slide-toggle #toggle [color]="primary" [checked]="true">Slide me</mat-slide-toggle>
<h3 [ngClass]="{'primary-color' : toggle.checked}">Text</h3>
CSS:
.primary-color {
color: red; // you should use theming to access the theme's primary color
}