Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

472
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda