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

185
Views
How to prevent onChange event from firing if a value is assigned dynamically?
 <ng-container *ngFor="let item of collectionValues">   
 <ion-checkbox slot="end" (ionChange)="onCheckBoxChange(item, $event)" 
        [(ngModel)]="item.value">
        </ion-checkbox>
 </ng-container>

This is ok but the problem is that if a value is assigned to item.value from the code in .ts i.e. then the onCheckBoxChange() is called which I don't want to. I have tried using the (click) event but that is not what I want. how do I prevent it from going to onCheckBoxChange event if a value is assigned. It should only go to the event if checked from UI.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As mentioned in the Angular Documentation you can use ngModelChange for your scenario

Event emitter for producing the ngModelChange event after the view model updates.

<ng-container *ngFor="let item of collectionValues">   
 <ion-checkbox slot="end" (ngModelChange)="onCheckBoxChange(item, $event)" 
        [(ngModel)]="item.value">
        </ion-checkbox>
 </ng-container>
about 4 years ago · Juan Pablo Isaza 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!