Angular 2中的禁用按钮

2022-01-21 00:00:00 input button javascript components angular

如果输入合同类型"为空,则保存"按钮不可点击

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"

相关文章