1

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.

9
  • is it happening on form load? Commented Sep 21, 2017 at 13:13
  • I use dialog window. Form is placed in dialog window. Commented Sep 21, 2017 at 13:14
  • That does not matter, if its a form it should work' Commented Sep 21, 2017 at 13:15
  • Does not work, I see that function return true Commented Sep 21, 2017 at 13:16
  • 1
    disabled means 'not clickable' - you won't necessarily see any style change unless you put some in i.e button[disabled] {background-color:red}. If you inspect the element in the dev tools you should see that it is disabled. Commented Sep 21, 2017 at 13:36

1 Answer 1

1

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

public hireDisableForm() {
    return !(this.person.birthDate && 
           this.person.passportNumber && 
           this.person.passportSerie);
}
Sign up to request clarification or add additional context in comments.

1 Comment

No matter, it return also true, but button is not disabled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.