在Angular 2中禁用按钮 [英] Disable Button in Angular 2
本文介绍了在Angular 2中禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想如果输入的合同类型"为空,则无法单击保存"按钮
I want if the input 'Contract type' is empty, the button 'Save' is not clickable
保存按钮:
<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>
定义合同类型:
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.',
}
]
};
按钮保存为绿色:
推荐答案
将ng-disabled="!contractTypeValid"
更改为[disabled]="!contractTypeValid"
这篇关于在Angular 2中禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文