A
A
Anton Ivanov2015-04-11 08:02:12
JavaScript
Anton Ivanov, 2015-04-11 08:02:12

How to make forms inactive during submit in AngularJS (globally)?

Hello!
There is a form, it has it <fieldset ng-disabled="processing">
when submitting the form, in the controller I set $scope.processing to true, after the execution of the controller method is completed, accordingly, I set it to false.
Within a small number of forms, this can be done by hand, but I wondered if there was some more global method?
I'm updating my question because I didn't seem to explain it very clearly.
I know how to make such functionality within one form. But the site will have a fairly large number of forms that are processed by different controllers. I want to understand if it is possible to add such functionality to all forms by default (for example, with some directive).
I.e. I know that it is possible to set processing to true in the form submit method first. Then, when the method is done, set processing to false. So, I want to add this processing setting to true and then false to all form submit methods. And in the future too.
That is, let's say I describe the form not with the "form" tag, but with the "myForm" tag, which is processed by some directive that sets processing to true on submit, then calls the real submit method, the one that is written in the form, and then , after the end of the real method, sets processing to false. In order not to write the same processing variable control in each submit method.
I hope I explained it better now
, thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-04-11
@Fly3110

You have already answered this question.
stackoverflow.com/questions/24119329/fieldset-and-...
You can write a directive for a form, you can define a fieldset directive so as not to change the markup...
If for a form, you can assign a promise to the attribute, and inside the directive track what happens when . At the end of the action, reset the promise and wait for the next one. Well, etc. So you can clean the controller from unnecessary things.
Example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question