AngularJS ng-disabled example

AngularJS ng-disabled directory is used to disable the controls. It will disable the element based on the return value of given {expression}. Below example will disable button, fieldset and all controls in fieldset when the check box selected by adding disabled attribute and re-enable elements when the checkbox unselected.

Below example will disable the button control whent the checkbox selected.

Below example will disable the fildset and all controls in the fildset(login controls)

User Name:


Source code

<html xmlns=""> <head> <title></title> <script src=""></script> </head> <body> <div ng-app="myApp" ng-controller="myCntrl"> <input type="checkbox" ng-model="disablebtn" id="chbbutton" name="chbbutton" /> <label for="chbbutton"> Select this checkbox to disable the below button</label> <br /> <br /> <input type="button" value="Disable Example" ng-disabled="disablebtn" /> <br /> <br /> <input type="checkbox" ng-model="disablefldset" id="chbfldset" name="chbfldset" /> <label for="chbfldset"> Select this checkbox to disable the fieldset and all controls</label> <br /> <br /> <fieldset ng-disabled="disablefldset"> User Name: <br /> <input type="text" /> <br /> <br /> Password: <br /> <input type="text" /> <br /> <br /> <input type="button" value="Login" /> </fieldset> </div> <script language="javascript"> var myapp = angular.module("myApp", []); myapp.controller("myCntrl", function ($scope) { $scope.disablebtn = false; $scope.disablefldset = false; }); </script> </body> </html>