ngModel.NgModelController.$setValidity()

$setValidity(validationErrorKey, isValid);

Change the validity state, and notify the form.

This method can be called within $parsers/$formatters or a custom validation implementation. However, in most cases it should be sufficient to use the ngModel.$validators and ngModel.$asyncValidators collections which will call $setValidity automatically.

Parameters

Param Type Details
validationErrorKey string

Name of the validator. The validationErrorKey will be assigned to either $error[validationErrorKey] or $pending[validationErrorKey] (for unfulfilled $asyncValidators), so that it is available for data-binding. The validationErrorKey should be in camelCase and will get converted into dash-case for class name. Example: myError will result in ng-valid-my-error and ng-invalid-my-error class and can be bound to as {{someForm.someControl.$error.myError}} .

isValid boolean

Whether the current state is valid (true), invalid (false), pending (undefined), or skipped (null). Pending is used for unfulfilled $asyncValidators. Skipped is used by Angular when validators do not run because of parse errors and when $asyncValidators do not run because any of the $validators failed.

doc_AngularJS
2016-03-29 16:12:16
Comments
Leave a Comment

Please login to continue.