Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS -- How to disable a form when it's being submitted?

Tags:

angularjs

How does one disable the complete form (all input elements within it), while it's being submitted via AJAX? I've tried setting a $scope.form_state variable in the controller and binding it to the submit button's ng-disabled attribute, but it seems like a workaround. There should be an easier + straight-forward way of doing this.

like image 752
Saurabh Nanda Avatar asked Feb 04 '13 05:02

Saurabh Nanda


People also ask

How to disable a field in AngularJS?

AngularJS ng-disabled Directive The ng-disabled directive sets the disabled attribute of a form field (input, select, or textarea). The form field will be disabled if the expression inside the ng-disabled attribute returns true.

How to make input disabled in Angular?

Disable the TextBox by adding the e-disabled to the input parent element and set disabled attribute to the input element.

How to disable a div in AngularJS?

You can't disable DIV . Disable work with button and input types only. You can try with css. Use ng-class.

How to disable button 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. Parameter value: expression: It represents an expression that returns true if it sets the disabled attribute for the element.


1 Answers

You can put all form elements into fieldset and use ng-disabled to disable the whole fieldset.

like image 189
Tosh Avatar answered Sep 29 '22 12:09

Tosh