This repository was archived by the owner on Jul 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Validation Callback
Ghislain B edited this page Dec 9, 2015
·
6 revisions
Since version 1.4.14
Validation Callback are useful when you want to run extra piece of code but only after the Validation is over.
Oh but wait a minute...
- But why do we need that?
- Shouldn't the Validation be super fast anyway?
The answer is yes but no. The validation when it runs is indeed super fast but the problem is that Angular-Validation has a debounce of 1 sec by default. The debounce basically waits for the user inactivity before doing any kind of validation. So the validation-callback will help dealing with this problem.
Internally the validation-callback is connected to a promise, it basically resolves whenever the validation is finished.
####Directive
<!-- defining the remote function call by using `custom:` -->
<input type="text" class="form-control"
name="input1"
ng-model="vm.model.input1"
validation="required"
validation-callback="myCallbackFunction()" />
<!-- or if you use the Controller As alias -->
<input type="text" class="form-control"
name="input1"
ng-model="vm.model.input1"
validation="required"
validation-callback="vm.myCallbackFunction()" />For a complete test case example, you could also look at my code sample in the folder more-examples/validationCallback
Contents
- Angular-Validation Wiki
- Installation
- Demo
- Code Samples
- Functionalities
- Custom Validations
- Properties & Options
- Validators
- Tests
- Misc