Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

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

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 ?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

not sure about the goal/use case but it is by design.

although it can be manipulated, it is highly recommended to rethink the UX of the goal. perhaps a different control or workflow

added a stackblitz that manipulate the state to be always true on control toggle:

https://stackblitz.com/edit/angular-elks1e?file=src/app/slide-toggle-overview-example.ts

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!