AngularJS Built-in directives ngDisabled


Example

This directive is useful to limit input events based on certain existing conditions.

The ng-disabled directive accepts and expression that should evaluate to either a truthy or a falsy values.

ng-disabled is used to conditionally apply the disabled attribute on an input element.

HTML

<input type="text" ng-model="vm.name">

<button ng-disabled="vm.name.length===0" ng-click="vm.submitMe">Submit</button>

vm.name.length===0 is evaluated to true if the input's length is 0, which is turn disables the button, disallowing the user to fire the click event of ng-click