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

Commit 64a142b

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 Closes #12416
1 parent 0026ebf commit 64a142b

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
@@ -1170,7 +1170,7 @@ function createDateInputType(type, regexp, parseDate, format) {
11701170

11711171
ctrl.$formatters.push(function(value) {
11721172
if (value && !isDate(value)) {
1173-
throw $ngModelMinErr('datefmt', 'Expected `{0}` to be a date', value);
1173+
throw ngModelMinErr('datefmt', 'Expected `{0}` to be a date', value);
11741174
}
11751175
if (isValidDate(value)) {
11761176
previousDate = value;
@@ -1247,7 +1247,7 @@ function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
12471247
ctrl.$formatters.push(function(value) {
12481248
if (!ctrl.$isEmpty(value)) {
12491249
if (!isNumber(value)) {
1250-
throw $ngModelMinErr('numfmt', 'Expected `{0}` to be a number', value);
1250+
throw ngModelMinErr('numfmt', 'Expected `{0}` to be a number', value);
12511251
}
12521252
value = value.toString();
12531253
}
@@ -1340,7 +1340,7 @@ function parseConstantExpr($parse, context, name, expression, fallback) {
13401340
if (isDefined(expression)) {
13411341
parseFn = $parse(expression);
13421342
if (!parseFn.constant) {
1343-
throw minErr('ngModel')('constexpr', 'Expected constant expression for `{0}`, but saw ' +
1343+
throw ngModelMinErr('constexpr', 'Expected constant expression for `{0}`, but saw ' +
13441344
'`{1}`.', name, expression);
13451345
}
13461346
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
};
@@ -597,7 +596,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
597596
forEach(ctrl.$asyncValidators, function(validator, name) {
598597
var promise = validator(modelValue, viewValue);
599598
if (!isPromiseLike(promise)) {
600-
throw $ngModelMinErr("$asyncValidators",
599+
throw ngModelMinErr("$asyncValidators",
601600
"Expected asynchronous validator to return a promise but got '{0}' instead.", promise);
602601
}
603602
setValidity(name, undefined);

0 commit comments

Comments
 (0)