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

Commit 034a8b2

Browse files
committed
fix(ngModel): correct minErr usage for correct doc creation
Remove the `new` from the minErr assignment, so the closure compiler can detect the errors correctly. Also removes the leading $ from the variable name to be consistent with the Angular.js file. Closes #12386
1 parent adb2863 commit 034a8b2

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/ng/directive/input.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
DIRTY_CLASS: false,
77
UNTOUCHED_CLASS: false,
88
TOUCHED_CLASS: false,
9-
$ngModelMinErr: false,
9+
ngModelMinErr: false,
1010
*/
1111

1212
// Regex code is obtained from SO: https://stackoverflow.com/questions/3143070/javascript-regex-iso-datetime#answer-3143231
@@ -1243,7 +1243,7 @@ function createDateInputType(type, regexp, parseDate, format) {
12431243

12441244
ctrl.$formatters.push(function(value) {
12451245
if (value && !isDate(value)) {
1246-
throw $ngModelMinErr('datefmt', 'Expected `{0}` to be a date', value);
1246+
throw ngModelMinErr('datefmt', 'Expected `{0}` to be a date', value);
12471247
}
12481248
if (isValidDate(value)) {
12491249
previousDate = value;
@@ -1319,7 +1319,7 @@ function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
13191319
ctrl.$formatters.push(function(value) {
13201320
if (!ctrl.$isEmpty(value)) {
13211321
if (!isNumber(value)) {
1322-
throw $ngModelMinErr('numfmt', 'Expected `{0}` to be a number', value);
1322+
throw ngModelMinErr('numfmt', 'Expected `{0}` to be a number', value);
13231323
}
13241324
value = value.toString();
13251325
}
@@ -1412,7 +1412,7 @@ function parseConstantExpr($parse, context, name, expression, fallback) {
14121412
if (isDefined(expression)) {
14131413
parseFn = $parse(expression);
14141414
if (!parseFn.constant) {
1415-
throw minErr('ngModel')('constexpr', 'Expected constant expression for `{0}`, but saw ' +
1415+
throw ngModelMinErr('constexpr', 'Expected constant expression for `{0}`, but saw ' +
14161416
'`{1}`.', name, expression);
14171417
}
14181418
return parseFn(context);

src/ng/directive/ngModel.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ var VALID_CLASS = 'ng-valid',
1616
TOUCHED_CLASS = 'ng-touched',
1717
PENDING_CLASS = 'ng-pending';
1818

19-
20-
var $ngModelMinErr = new minErr('ngModel');
19+
var ngModelMinErr = minErr('ngModel');
2120

2221
/**
2322
* @ngdoc type
@@ -268,7 +267,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
268267
}
269268
};
270269
} else if (!parsedNgModel.assign) {
271-
throw $ngModelMinErr('nonassign', "Expression '{0}' is non-assignable. Element: {1}",
270+
throw ngModelMinErr('nonassign', "Expression '{0}' is non-assignable. Element: {1}",
272271
$attr.ngModel, startingTag($element));
273272
}
274273
};
@@ -599,7 +598,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
599598
forEach(ctrl.$asyncValidators, function(validator, name) {
600599
var promise = validator(modelValue, viewValue);
601600
if (!isPromiseLike(promise)) {
602-
throw $ngModelMinErr("$asyncValidators",
601+
throw ngModelMinErr("$asyncValidators",
603602
"Expected asynchronous validator to return a promise but got '{0}' instead.", promise);
604603
}
605604
setValidity(name, undefined);

0 commit comments

Comments
 (0)