Изменить стиль текста с помощью mat-slide-toggle - PullRequest
0 голосов
/ 26 апреля 2018

Как я могу изменить стиль текста, используя мат-слайд-переключатель Ang-Material-2?

enter image description here

<mat-slide-toggle [color]="primary" [checked]="true">Slide me</mat-slide-toggle>
<h3>Text</h3>

1 Ответ

0 голосов
/ 26 апреля 2018

Привязать свойство класса или стиля к элементу <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
}
...