要在 Angular Material 的 mat-checkbox 和 mat-radio 被选中时改变标签文本的颜色,可以使用 Angular 的双向绑定和 CSS 样式来实现。以下是一个示例解决方案:
selected
,用于改变文本颜色。选项一
选项一
选项二
selected
类的样式,以更改文本颜色。.selected {
color: red; // 选中时要应用的文本颜色
}
import { Component } from '@angular/core';
@Component({
selector: 'app-example',
templateUrl: './example.component.html',
styleUrls: ['./example.component.css']
})
export class ExampleComponent {
checkboxValue: boolean = false;
radioValue: string = '';
}
通过以上步骤,当 mat-checkbox 和 mat-radio 被选中时,标签文本的颜色会改变为红色。
请注意,这只是一个示例解决方案,你可以根据自己的需求进行更改和扩展。