POV
POV

Reputation: 12025

How to disable button Angular?

I tried this function:

public hireDisableForm() {
    const dis =  this.person.birthDate == '' || this.person.passportNumber == '' || this.person.passportSerie == '';
    return (!dis) ? null : dis;
  }

It return me true, I checked this in console.log().

Using:

<button class="hire1" [disabled]="hireDisableForm()">Save</button>

It does not disable button.

Upvotes: 1

Views: 119

Answers (1)

Faly
Faly

Reputation: 13356

You do it in so complicated way! You can do it simpler:

public hireDisableForm() {
    return !(this.person.birthDate && 
           this.person.passportNumber && 
           this.person.passportSerie);
}

Upvotes: 1

Related Questions