I tried everything I could to trigger events when the checkbox changes, but I can't get it to work.
Here is the html
<div *ngIf="role?.ACTIVE_FLAG === 'Y'"> <div class="label"> Active Record </div> <input type="checkbox" (click)="toggleRoleActive()" checked> </div> <div *ngIf="role?.ACTIVE_FLAG === 'N'"> <div class="label"> Active Record </div> <input type="checkbox" (click)="toggleRoleActive()"> </div>
Here is the toggleRoleActive ()
Edit:
toggleRoleActive(){ if(this.role_submit.ACTIVE_FLAG === 'Y'){ this.role_submit.ACTIVE_FLAG = 'N'; }else { this.role_submit.ACTIVE_FLAG = 'Y'; } }
One of the problems I encountered is a button that needs to either be checked or not checked when I receive data from the server. But if they want to deactivate or reactivate the role, I would like her to answer this checkbox.
I tried using [(ngModel)] , (change) and much simpler solutions, but the only thing that triggered any events at all was [(ngModel)] , but in doing so I get true / false instead of 'Y' / 'N' . Also, if I use [(ngModel)] , the flag is always checked, regardless of what data my server sends.
source share