jw-bootstrap-switch-ng2 icon indicating copy to clipboard operation
jw-bootstrap-switch-ng2 copied to clipboard

Behaviour state change of switch even if value not change.

Open Dhairya312 opened this issue 4 years ago • 0 comments

Bug Report or Feature Request.

#Issue# ###Angular 7# Here switch in html section:- <bSwitch [(ngModel)]="branch.isDefault" formControlName="isDefault" [switch-on-text]="'YES'" [switch-off-text]="'No'" [switch-size]="'mini'" (changeState)="onBranchDefault($event)"> </bSwitch> {{branch.isDefault}}

Here is Ts code:- onBranchDefault(i: number, event: {currentValue: boolean, previousValue: boolean}) { this.data.branchDetails[i].isDefault = false; const defaultBranch = this.data.branchDetails.find((def) => def.isDefault); if (event.currentValue) { if (defaultBranch) { const confirmIS = confirm('Are sure want to override Default Branch?'); if (confirmIS) { this.data.branchDetails[i].isDefault = true; let previousDefaultBranch = this.data.branchDetails.indexOf(defaultBranch); this.data.branchDetails[previousDefaultBranch].isDefault = false; return; } return; } this.data.branchDetails[i].isDefault = true; } }

when confirmation is cancel the value which bind with [(ngModel)] will remain same but the Behaviour of the switch changes, like if the switch is false that time on click the confirm message open that time when event get cancel the value will remain false but the behaviour of the switch is set to true.

Dhairya312 avatar Jan 22 '21 06:01 Dhairya312