-6ren">
gpt4 book ai didi

javascript - 在 Angular 2 中禁用按钮

转载 作者:太空狗 更新时间:2023-10-29 16:48:24 25 4
gpt4 key购买 nike

我希望如果输入的“契约(Contract)类型”为空,则“保存”按钮不可点击

保存按钮:

<div class="col-md-4">
<cic-textbox [control]="formGroup.get('contractType')"></cic-textbox>
</div>

所有按钮:

 <div class="cic-header-actions pull-left" *ngIf="actions && actions.length > 
0">
<button class="btn btn-{{action.style}} m-l-xs" *ngFor="let action of actions" ng-disabled="!contractTypeValid" (click)="execute(action)">
<cic-icon [icon]="action.icon"></cic-icon>
{{action.text }}
</button>
</div>

定义契约(Contract)类型:

 let contractType: DataDictionaryPropertyExtended = {
Binding: 'VART:BEZEICHNUNG',
Label: 'Vertragsart',
LabelCols: 4,
ContentCols: 8,
IsDisabled: this.isDisabled,
ValidationProperties: [
<ValidationProperty>{
Type: ValidationType.IsNotEmpty,
ErrorMessage: 'Vertragsart darf nicht leer sein.',
}
]
};

按钮保存绿色:

enter image description here

最佳答案

ng-disabled="!contractTypeValid" 更改为 [disabled]="!contractTypeValid"

关于javascript - 在 Angular 2 中禁用按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43978380/

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