How to disable buttons using AngularJS ? Last Updated : 01 Aug, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how to disable the button using the particular directive in AngularJS. Sometimes, we need to disable the button, and link on the click event. This task can be accomplished by implementing the ng-disabled directive that is used to enable or disable HTML elements. Syntax: <element ng-disabled="expression"> Contents... </element>Parameter value: expression: It represents an expression that returns true if it sets the disabled attribute for the element.This directive can be utilized to set the form field such as input, select, or textarea, with having the disabled attribute, i.e. it is supported by <input>, <select>, and <textarea> elements. Example 1: This example illustrates the ng-disabled directive by disabling the button. HTML <!DOCTYPE HTML> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"> </script> <script> var myApp = angular.module("app", []); myApp.controller("controller", function($scope) { $scope.disabledFlag = false; $scope.disableIt = function() { $scope.disabledFlag = true; }; }); </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h3> Disable the button in AngularJS </h3> <div ng-app="app"> <div ng-controller="controller"> <button ng-click='disableIt()' ng-disabled='disabledFlag'> Click to disable </button> </div> </div> </body> </html> Output: Example 2: This example illustrates the implementation of the ng-disabled directive to disable multiple buttons. HTML <!DOCTYPE HTML> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"> </script> <script> var myApp = angular.module("app", []); myApp.controller("controller", function($scope) { $scope.disabledFlag1 = false; $scope.disableIt1 = function() { $scope.disabledFlag1 = true; }; $scope.disabledFlag2 = false; $scope.disableIt2 = function() { $scope.disabledFlag2 = true; }; $scope.disabledFlag3 = false; $scope.disableIt3 = function() { $scope.disabledFlag3 = true; }; $scope.disabledFlag = false; $scope.disableIt = function() { $scope.disabledFlag1 = true; $scope.disabledFlag2 = true; $scope.disabledFlag3 = true; }; }); </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h3> Disable the button in AngularJS </h3> <div ng-app="app"> <div ng-controller="controller"> <button ng-click='disableIt1()' ng-disabled='disabledFlag1'> disable it </button> <button ng-click='disableIt2()' ng-disabled='disabledFlag2'> disable it </button> <button ng-click='disableIt3()' ng-disabled='disabledFlag3'> disable it </button> <br> <br> <button ng-click='disableIt()' ng-disabled='disabledFlag'> disable All </button> </div> </div> </body> </html> Output: Comment More infoAdvertise with us Next Article AngularJS ng-disabled Directive P PranchalKatiyar Follow Improve Article Tags : AngularJS HTML-Misc AngularJS-Misc Similar Reads Angular PrimeNG Focus Trap Disabled Button Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use the Focus Trap Disabled Button in Angular PrimeNG. We will also 3 min read How to Disable a Button in jQuery UI ? To disable a button in jQuery UI, we will be using disable() method which is discussed below: jQuery UI disable() method is used to completely disable the button. It returns the button element completely to its initial state. Syntax: $(".selector").button("disable") Parameters: This method does not 2 min read How to make buttons using Angular UI Bootstrap ? In this article, we will see how to make buttons using Angular UI bootstrap. Angular UI Bootstrap is an Angular JS framework created by Angular UI developers for providing better UI which can be used easily. Buttons directive is used for making buttons. Syntax: <buttonclass='btn btn-primary'>b 2 min read Angular Material Button Toggle Angular Material is a UI component library that is developed by Google so that Angular developers can develop modern applications in a structured and responsive way. By making use of this library, we can greatly increase the user experience of an end-user thereby gaining popularity for our applicati 4 min read AngularJS ng-disabled Directive In this article, we will see the AngularJS ng-disabled Directive, along with understanding its implementation through the illustrations. The ng-disabled Directive in AngularJS is used to enable or disable the HTML elements. If the expression inside the ng-disabled attribute returns true then the for 2 min read How to disable a form control in Angular ? In this article, we are going to see how to disable a form control in Angular 10. We will use AbstractControl disabled property to disable a form control element. Syntax: <formelement disabled></formelement> Return Value: boolean: returns boolean stating whether the element is disabled o 2 min read Like