根据反应形式或输入状态有条件地禁用按钮

问题描述 投票:0回答:2

我有一个带有文本区域的反应形式trainingFeedbackForm

<textarea pInputTextarea appWhiteSpace inputField="{{not_attended_reason}}"
    [(ngModel)]="not_attended_reason" [disabled]="attended==='yes'"
    placeholder="The reason for not attending the traning"
    (inputValue)="removeWhitespace($event)"></textarea>

当表单有效或文本区域为空时,我想禁用此按钮:

<button (click)="getFeedbackFormValue()" class="btn-gradient fill-btn ripple"
    [disabled]="trainingFeedbackForm.invalid || !not_attended_reason">
    Submit feedback
</button>

我上面使用的方法不起作用。

我该如何实现?有人可以帮忙吗?

angular angular-ngmodel
2个回答
0
投票

这应该可以解决问题,只需添加!trainingFeedbackForm.invalid


0
投票

component.html in替换disabled="checkDisbled()"

© www.soinside.com 2019 - 2024. All rights reserved.