This repository has been archived by the owner on Jul 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Global Options
Ghislain B. edited this page Jul 16, 2015
·
38 revisions
To change default options globally, you can use the $scope.$validationOptions
. These global options can be defined for both the Directive and/or the Service.
######Directive/Service
myApp.controller('Ctrl', function ($scope) {
$scope.$validationOptions = {
// set the debounce globally
debounce: 1500,
// display only last error message on each input element (false by default)
// for example if 3 errors are on the element, only the last message would show up
displayOnlyLastErrorMsg: false,
// set which scope Angular-Validation will use
// mainly used by $validationSummary and some Service functions like checkFormValidity(), resetForm(), removeValidator()
isolatedScope: $scope,
// pre-validate all form elements, false by default
preValidateFormElements: false
};
});
All of these options can also be defined with the Service but this will only works when all your elements have been defined by the Angular-Validation Service ######Service Only
myApp.controller('Ctrl', function ($scope) {
// start by creating the service
var myValidation = new validationService();
// define the scope and isolatedScope, the scope property always needs to be there
myValidation.setGlobalOptions({
// set the debounce globally
debounce: 1500,
// display only last error message on each input element (false by default)
// for example if 3 errors are on the element, only the last message would show up
displayOnlyLastErrorMsg: false,
// set which scope Angular-Validation will use, mainly for $validationSummary and checkFormValidity()
// scope & isolatedScope are equivalent but scope is mandatory while isolatedScope is not, so it is suggested to just use scope:
scope: $scope,
isolatedScope: $scope,
// pre-validate all form elements, false by default
preValidateFormElements: false
});
});
Contents
- Angular-Validation Wiki
- Installation
- Demo
- Code Samples
- Functionalities
- Custom Validations
- Properties & Options
- Validators
- Tests
- Misc