关闭角度2的按钮

我想如果输入“合同类型”是空的,按钮“保存”是不可点击的

保存按钮:

<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.',
}
]
};

按钮保护绿色:

enter image description here

200766 次浏览

Change ng-disabled="!contractTypeValid" to [disabled]="!contractTypeValid"

I tried use [disabled]="!editmode" but it not work in my case.

This is my solution [disabled]="!editmode ? 'disabled': null" , I share for whom concern.

<button [disabled]="!editmode ? 'disabled': null"
(click)='loadChart()'>
<div class="btn-primary">Load Chart</div>
</button>

Stackbliz https://stackblitz.com/edit/angular-af55ep