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

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

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