When validating an email and password input using AngularJS, I can check for the following conditions:
myForm.$error.required
This checks if the input fields are required and have values. I can also validate the email input using the following:
myForm.email.$valid
This checks the email input against a regex pattern. When printing the result using {{ the above code }}, I can see the boolean validation result for both inputs, which is correct. However, when I try to use ng-disabled on a button with both expressions, it does not work. If I use ng-disabled with only one expression it works, but I am unable to combine both expressions like this:
<button type="submit" ng-disabled="myForm.$error.required && !myForm.email.$valid">Sign in</button>
The issue seems to be that the result is true based on the first expression alone. I thought using && meant that both conditions needed to be met in order for it to result in true. Could it be because true + false equals true in this case?