Disable Button in Angular 2

I want if the input 'Contract type' is empty, the button 'Save' is not clickable

Save button:

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

ALL Buttons:

 <div *ngIf="actions && actions.length > 0"> <button *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:

enter image description here

1

2 Answers

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

2

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>Load Chart</div> </button> 

Stackbliz

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like