gpt4 book ai didi

javascript - 如何以 Angular 启用提交按钮

转载 作者:行者123 更新时间:2023-11-30 09:10:44 25 4
gpt4 key购买 nike

代码如下:

list.component.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>

list.component.ts

  disableSubmitBtn() {
if (!this.otherRemark) {
return true;
}
}

如何在 Angular 选择passed启用提交按钮。

我想要的是,在 radio button 上选择 passed 后,它应该enable submit button 如果它选择 failed buttondisabled 它应该首先填写备注,这是 textarea函数 disableSubmit()

if (!this.otherRemark) {
return true;
}

提前致谢

最佳答案

Try this:

 <button [disabled]="radioValue === 'passed' ?  !(radioValue === 'passed') : !(radioValue === 'failed' && otherRemark)" class="mr-1" nz-button nzType="primary" type="button" 
[nzLoading]="formLoading" (click)="saveFormData()">
<span translate>Submit</span>
</button>

关于javascript - 如何以 Angular 启用提交按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59299203/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com