AngularJS ng-disabled – conditionally disable an element

AngularJS directive ng-disabled sets the disabled attribute on the element if the expression ng-disabled evaluates to true.

<div ng-app="myApp" ng-controller='MyCtrl'>
  <label>Select checkbox to disable: <input type="checkbox" ng-model="disableButton"></label><br/>
  <button ng-model="button1" ng-disabled="disableButton">Button</button>
</div>

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>
<script>
  var module = angular.module('myApp', []);
  module.controller('MyCtrl', function($scope) {});
</script>
refresh
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments