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

136
Visualizações
mat-checkbox targeting both elements on same click

I have one mat-checkbox which is also part of mobile version.

When we have two separate parts, one for desktop and one for mobile. The desktop <mat-checkbox> works on select and unselect properly, whereas the mobile option when we click triggers the desktop version checkbox instead of just selecting and unselecting the mobile version.

How to let <mat-checkbox> handle both events separately independent of each other?

HTML:

<div class="class-a">
  <label
    [ngClass]="{'class-b': valueTrigger}">
    <mat-checkbox
      class="checkbox"
      [(ngModel)]="valueTrigger"
      (input)="toggleHasTrigger($event.target.checked)"
      id="test"
      type="checkbox"
      name="testing" ngDefaultControl
    >
      I am here!
    </mat-checkbox>
  </label>
</div>

TS:

initValueTrigger(): void {
    this.valueTrigger = !this.asset.Unchecked;
    this.toggleHasTriggerEvent.emit(this.valueTrigger);
  }
    
toggleHasTrigger(toggleValue: boolean): void {
        this.asset.Unchecked = !toggleValue;
        this.valueTrigger = toggleValue;
        this.toggleHasTriggerEvent.emit(this.valueTrigger);
      }
about 4 years ago · Santiago Gelvez
2 Respostas
Responde à pergunta

0

You might want to provide separate ids to the checkboxes for both mobile and web views

For example: test_web and test_mobile

about 4 years ago · Santiago Gelvez Relatório

0

I used the for instead of id after the above answer to have separate ids to the checkboxes:

for="test"
about 4 years ago · Santiago Gelvez 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