I have the following checkbox:
<mat-checkbox [(ngModel)]="anuncio.checkouCarimbo" (click)="checkouAnuncio()" name="checksegundoAnuncio"
class="example-margin checkFoto">
</mat-checkbox>
The function called by the checkbox when it is clicked:
checkouAnuncio(){
for(let i=0;i<this.anuncios.length;i++){
if(this.anuncios[i].checkouCarimbo == true){
this.habilitaCarimbar = true;
return;
}else{
this.habilitaCarimbar = false;
}
}
}
My goal is to go through the ads array and if at any position check it, it is true, set the this.disable_value field, but clicking the function is called and then it is set to ngModel, so my logic is broken. Is there any way to get the value first and then run the function or follow that order anyway?