[英]Disable Button in Angular 2
I want if the input 'Contract type' is empty, the button 'Save' is not clickable我想如果输入“合同类型”为空,则“保存”按钮不可点击
Save button:保存按钮:
<div class="col-md-4">
<cic-textbox [control]="formGroup.get('contractType')"></cic-textbox>
</div>
ALL Buttons:所有按钮:
<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>
Definition contractType:定义合同类型:
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.',
}
]
};
BUTTON SAVE GREEN:按钮保存绿色:
将ng-disabled="!contractTypeValid"
更改为[disabled]="!contractTypeValid"
I tried use [disabled]="!editmode"
but it not work in my case.我尝试使用
[disabled]="!editmode"
但它在我的情况下不起作用。
This is my solution [disabled]="!editmode ? 'disabled': null"
, I share for whom concern.这是我的解决方案
[disabled]="!editmode ? 'disabled': null"
,我为谁担心。
<button [disabled]="!editmode ? 'disabled': null"
(click)='loadChart()'>
<div class="btn-primary">Load Chart</div>
</button>
Stackbliz https://stackblitz.com/edit/angular-af55ep Stackbliz https://stackblitz.com/edit/angular-af55ep
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.