Spilot
Spilot

Reputation: 1525

Any simple way in ionic2/angular2 to disable button if a text input area is empty?

I'm trying to use an *ngIf conditional on a button in order to disable it if a text input area is empty, but there doesn't seem to be a straightforward way to access that input value.

<ion-item>

<ion-label fixed>Venue</ion-label>

    <ion-input type="text" id="venue" [(ngModel)]="event.venue" class="form-control" maxlength="22" required></ion-input> 

    </ion-item>

<button ion-button block id="addEventButton" *ngIf="//not sure what to do here// " (click)="addEvent();">Add Event</button>

Upvotes: 1

Views: 276

Answers (1)

Dinesh Raja
Dinesh Raja

Reputation: 117

Yeah this will work

<button ion-button block id="addEventButton" [disabled]="!event.venue"></button>

Upvotes: 1

Related Questions