3

I am looking for a way to do exactly opposite from this example that was taken from angularjs ng-disabled documentation ... http://docs.angularjs.org/api/ng.directive:ngDisabled

In this example checking the box disables the button. I need exactly the opposite,,, I need the checked box to enable a disabled button. Can someone shed some light on this for me please.

<!doctype html>
<html ng-app>
<head>
<script src="http://code.angularjs.org/1.2.0/angular.min.js"></script>
</head>
<body>
Click me to toggle: <input type="checkbox" ng-model="checked"><br/>
<button ng-model="button" ng-disabled="checked">Button</button>
</body>
</html>

Thanks!

1 Answer 1

11

You can do:

ng-disabled="!checked"

The ! means to do the opposite, so !true == false = true

Plunkr: http://plnkr.co/edit/ht0z3lTJi8EfPJEKWcWl?p=preview

Sign up to request clarification or add additional context in comments.

2 Comments

Oh gosh!! I keep forgetting this thing is pretty flexible :) Thank you!
Baller assed answer bro. Nice.

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.