I have a form with a submit button, the form will take 10 seconds to come back and I don’t want the user to be clicking on the form meanwhile. My approach so far has been setting the text of the button to buttonText="Loading..." and using ng-disable with a flag that I’m setting when I do the submit(isSubmitted). Considering this must be a general pattern, what is the best and most reusable way of doing this?
I have a form with a submit button, the form will take 10 seconds
Share
Create a reusable component with a custom directive. The directive should create an isolate scope and use the ‘&’ syntax to specify which parent scope function to call when the button is clicked. Pass a callback function so the directive can undo the button label change and the disabled attribute when the task is completed.
HTML:
Directive:
Fiddle