<form [formGroup]="businessFoodHygieneForm">
<div class="box p-4 d-flex jc-between ai-center">
<span>
Food Hygiene Link
</span>
<label>
<nz-switch
class="switch-middle ms-2"
formControlName="foodHygieneLink"
(ngModelChange)="onFoodHygieneChange($event)">
</nz-switch>
</label>
</div>
</form>
ts component:
foodHygieneLink: new FormControl(''),
this.businessFoodHygieneForm.patchValue({
foodHygieneLink:
selectedBusiness?.foodHygieneLink,
});
onFoodHygieneChange(status: boolean): void {
this.foodHygieneLink = status;
const body = { foodHygieneLink: status ? 'Yes' : 'No' };
this.bizStore.dispatch(
businessAction.updateBusiness({
body: body,
bid: this.bid,
})
);
}
The functionality using nz-switch
was successfully implemented but there is a bug where the switch button does not work correctly when set to "No". It should be in the off position, however it remains on.