mat-slide-toggle [checked] attribute doesn't seem to work

Viewed 995

I have a <mat-slide-toggle> which I defined as such :

<mat-slide-toggle [checked]="synchronizationState === 'ENABLED'"
                  [disabled]="!canChangeSynchronizationState"
                  formControlName="enableSynchronization"
                  #enableSynchronizationToggle
                  (change)="openConfirmSynchronizationStateDialog(enableSynchronizationToggle.checked)">
</mat-slide-toggle>

However, when the user clicks on the toggle, it changes state not matter what (if it was checked, it goes unchecked and vice-versa), even if synchronizationState hasn't changed.

I've further tested the component like such : <mat-slide-toggle [(ngModel)]="checked" [checked]="checked"></mat-slide-toggle> where checked = false; and it appears I can still change the state of the toggle.

It looks like the mat-slide-toggle doesn't care at all about what I input in [checked], what am I doing wrong here ?

1 Answers
Related