Austin Davis
Austin Davis

Reputation: 3756

angular form validation not working as expected

I'm trying to keep a button disabled under two conditions. The first is if a required fields condition has been meet (is there isn't text in the input) the second is if the Boolean value is false. The problem is for some reason my directive seems to acting like an or rather than an And where the button becomes enabled after either one of the two conditions is meet.

Here is the button I'm trying to keep disabled when both conditions aren't met

<button type="button" id ='submission' class="btn btn-success ng-hide" ng-show="submissionReady" ng-hide="afterSubmission" ng-click="saveScenario()" ng-disabled="myForm.title.$invalid && !playerService.status">Save Scenario</button>

Upvotes: 0

Views: 57

Answers (1)

JB Nizet
JB Nizet

Reputation: 691715

You want the button to be disabled if one of the conditions is true. Not if both conditions are true. So you need an OR, not an AND:

ng-disabled="myForm.title.$invalid || !playerService.status"

Upvotes: 1

Related Questions