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 Aug 19, 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.
For more details about the ControllerAs
option, please refer to the Wiki - ControllerAs Syntax
####Available Global Options
// use the ControllerAs syntax
controllerAs: vm,
// 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 by checkFormValidity(), resetForm(), removeValidator()
isolatedScope: $scope,
// pre-validate all form elements, False by default
preValidateFormElements: false
// reset Global Options on Route Change, True by default
resetGlobalOptionsOnRouteChange: true
####Examples ######Directive/Service
myApp.controller('Ctrl', function ($scope) {
$scope.$validationOptions = { debounce: 1500, /* etc... */ };
});
All of these options can also be defined using the Service.
######Service
// inject the validationService inside your Controller
myApp.controller('Ctrl', function ($scope, validationService) {
// start by creating the service
var myValidation = new validationService();
// define the scope and isolatedScope, the scope property always needs to be there
myValidation.setGlobalOptions({ debounce: 1500, /* etc... */ });
});
Instead of calling the setGlobalOptions()
, you could alternatively also directly use the validationService
Constructor which is much shorter syntax:
// using the constructor
var myValidation = new validationService({ controllerAs: vm, debounce: 1500 });
Contents
- Angular-Validation Wiki
- Installation
- Demo
- Code Samples
- Functionalities
- Custom Validations
- Properties & Options
- Validators
- Tests
- Misc