-
Notifications
You must be signed in to change notification settings - Fork 15
Description
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)">
{{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.