Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit f211419

Browse files
twhitbeckcaitp
authored andcommitted
docs(ngModelController): fix $asyncValidators example
Also fixes a typo (◜௰◝) Closes #8906
1 parent 5dd9f13 commit f211419

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/ng/directive/input.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ var VALID_CLASS = 'ng-valid',
14471447
* perform an asynchronous validation (e.g. a HTTP request). The validation function that is provided
14481448
* is expected to return a promise when it is run during the model validation process. Once the promise
14491449
* is delivered then the validation status will be set to true when fulfilled and false when rejected.
1450-
* When the asynchronous validators are trigged, each of the validators will run in parallel and the model
1450+
* When the asynchronous validators are triggered, each of the validators will run in parallel and the model
14511451
* value will only be updated once all validators have been fulfilled. Also, keep in mind that all
14521452
* asynchronous validators will only run once all synchronous validators have passed.
14531453
*
@@ -1457,12 +1457,14 @@ var VALID_CLASS = 'ng-valid',
14571457
* ```js
14581458
* ngModel.$asyncValidators.uniqueUsername = function(modelValue, viewValue) {
14591459
* var value = modelValue || viewValue;
1460+
*
1461+
* // Lookup user by username
14601462
* return $http.get('/api/users/' + value).
1461-
* then(function() {
1462-
* //username exists, this means the validator fails
1463-
* return false;
1464-
* }, function() {
1465-
* //username does not exist, therefore this validation is true
1463+
* then(function resolved() {
1464+
* //username exists, this means validation fails
1465+
* return $q.reject('exists');
1466+
* }, function rejected() {
1467+
* //username does not exist, therefore this validation passes
14661468
* return true;
14671469
* });
14681470
* };

0 commit comments

Comments
 (0)