Here's the code snippet:
SampleComponent.html
<nz-radio-group formControlName="radiostatus" [(ngModel)]="radioValue" (ngModelChange)="onChangeStatus($event)">
<label nz-radio nzValue="passed">Passed</label>
<label nz-radio nzValue="failed">Failed</label>
</nz-radio-group>
<div *ngIf="radioValue ==='failed'>
<textarea nz-input placeholder="Remarks" class="remarks-textarea" type="text" name="otherRemark"
formControlName="otherRemark" [(ngModel)]="otherRemark"
[nzAutosize]="{ minRows: 3, maxRows: 3 }"></textarea>
</div>
<button class="mr-1" nz-button nzType="primary" type="button" [disabled]="disableSubmitBtn()"
[nzLoading]="formLoading" (click)="saveFormData()">
<span translate>Submit</span>
</button>
SampleComponent.ts
disableSubmitBtn() {
if (!this.otherRemark) {
return true;
}
}
How can I dynamically enable the submit button when "passed" is selected in Angular?
My requirement is that upon selecting "passed" on the radio button, the submit button should become enabled. If "failed" is selected, the button should be disabled until the remarks are filled in the textarea as per the disableSubmit function.
if (!this.otherRemark) {
return true;
}
Thank you for your help!