When key checkbox is checked, I want to check and disable mandatory checkbox
HTMLcode
<input class="form-check-input" type="checkbox" formControlName="key" id="keyCheckbox" (click)="keyCheckboxClick()">
<label for="keyCheckbox" class="form-check-label mr-sm-2">Key</label>
<input class="form-check-input" formControlName="mandatory" type="checkbox" id="mandatoryCheckbox">
<label for="mandatoryCheckbox" class="form-check-label mr-sm-2">Mandatory</label>
Typescript code for checkbox
keyCheckboxClick() {
let x = <HTMLInputElement>document.getElementById("keyCheckbox");
let y = <HTMLInputElement>document.getElementById("mandatoryCheckbox");
if (x.checked) {
y.checked = true;
y.disabled = true;
}
else {
y.checked = false;
y.disabled = false;
}
}
By using this code Mandatory checkbox is checked and disabled. But the boolean value of Mandatory checkbox remains false. Any suggestions on how can I change the boolean value of Mandatory checkbox to true when I click key checkbox I am using Angular 8 and its reactive forms module.I am new to angular. Thanks in Advance.It's urgent!!
Aucun commentaire:
Enregistrer un commentaire