Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda