json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

Determining when validation is complete #686

Open AndrewIsh opened 8 years ago

AndrewIsh commented 8 years ago

Enhancement

Sending the 'schemaFormValidate' broadcast prompts a validation of the form. However, if you then want to perform an action dependent on the form's $valid property immediately after the validation, there is no way of knowing when the validation is complete. This can lead to a race condition whereby the testing of the form's $valid property occurs before the validation is complete.

Expected behaviour

Either prompting form validation should be done via a method call that returns a promise or, maybe, upon form validation, ASF should send a broadcast announcing the fact.

@json-schema-form/angular-schema-form-lead

Anthropic commented 7 years ago

@AndrewIsh does a scope.$apply(); not wait for it to complete?

AndrewIsh commented 7 years ago

@Anthropic I'm not sure how this would be implemented. If I'm sending a schemaFormValidate broadcast, that's a fire and forget. I'm not sure I understand how scope.$apply() could be used in this context. Apologies if I'm being dim ;-)