Enable/Disable DOM Elements Conditionally

Description

To disable a button depending on a checkbox state, use the ng-disabled directive and bind its condition to the checkbox state.

The following code shows how to enable/Disable DOM Elements Conditionally.

Example


<!--from w  w  w. j a  v a2 s.co  m-->



<!doctype html>
<html ng-app>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script>
  </head>
  <body ng-app>
    <label><input type="checkbox" ng-model="checked"/>Toggle Button</label>
    <button ng-disabled="checked">Press me</button>
  </body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities