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

129
Views
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 answers
Answer question

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 Report

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 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!