@@ -1447,7 +1447,7 @@ var VALID_CLASS = 'ng-valid',
1447
1447
* perform an asynchronous validation (e.g. a HTTP request). The validation function that is provided
1448
1448
* is expected to return a promise when it is run during the model validation process. Once the promise
1449
1449
* 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
1451
1451
* value will only be updated once all validators have been fulfilled. Also, keep in mind that all
1452
1452
* asynchronous validators will only run once all synchronous validators have passed.
1453
1453
*
@@ -1457,12 +1457,14 @@ var VALID_CLASS = 'ng-valid',
1457
1457
* ```js
1458
1458
* ngModel.$asyncValidators.uniqueUsername = function(modelValue, viewValue) {
1459
1459
* var value = modelValue || viewValue;
1460
+ *
1461
+ * // Lookup user by username
1460
1462
* 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
1466
1468
* return true;
1467
1469
* });
1468
1470
* };
0 commit comments