How do I add multiple conditions to "ng-disabled"?

Viewed 140440

I need to check that two conditions are both true before enabling a button:

Here is an example:

<button type="submit" ng-disabled="frmUser.pw2.$error.pwMatch" class="btn btn-primary" ng-click="ChangePassword()">Change</button>

This example only contains one condition within ng-disabled. How would I add another such as a scope variable?

8 Answers

You can try something like this.

<button class="button" ng-disabled="(!data.var1 && !data.var2) ? false : true">
</button>

Its working fine for me.

Both variable must be false for the button to be disabled:

<button class="button" ng-disabled="(!data.var1 && !data.var2) ? false : true">
</button>

this way worked for me

ng-disabled="(user.Role.ID != 1) && (user.Role.ID != 2)"

Related