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

Commit 2354924

Browse files
shahatapetebacondarwin
authored andcommitted
refactor(ngModelController): use 'ctrl' instead of 'this'
1 parent 940fcb4 commit 2354924

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/ng/directive/input.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,20 +1659,20 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
16591659
if ($error[validationErrorKey]) invalidCount--;
16601660
if (!invalidCount) {
16611661
toggleValidCss(true);
1662-
this.$valid = true;
1663-
this.$invalid = false;
1662+
ctrl.$valid = true;
1663+
ctrl.$invalid = false;
16641664
}
16651665
} else {
16661666
toggleValidCss(false);
1667-
this.$invalid = true;
1668-
this.$valid = false;
1667+
ctrl.$invalid = true;
1668+
ctrl.$valid = false;
16691669
invalidCount++;
16701670
}
16711671

16721672
$error[validationErrorKey] = !isValid;
16731673
toggleValidCss(isValid, validationErrorKey);
16741674

1675-
parentForm.$setValidity(validationErrorKey, isValid, this);
1675+
parentForm.$setValidity(validationErrorKey, isValid, ctrl);
16761676
};
16771677

16781678
/**
@@ -1686,8 +1686,8 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
16861686
* state (ng-pristine class).
16871687
*/
16881688
this.$setPristine = function () {
1689-
this.$dirty = false;
1690-
this.$pristine = true;
1689+
ctrl.$dirty = false;
1690+
ctrl.$pristine = true;
16911691
$animate.removeClass($element, DIRTY_CLASS);
16921692
$animate.addClass($element, PRISTINE_CLASS);
16931693
};
@@ -1713,30 +1713,30 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
17131713
*/
17141714
this.$cancelUpdate = function() {
17151715
$timeout.cancel(pendingDebounce);
1716-
this.$render();
1716+
ctrl.$render();
17171717
};
17181718

17191719
// update the view value
17201720
this.$$realSetViewValue = function(value) {
1721-
this.$viewValue = value;
1721+
ctrl.$viewValue = value;
17221722

17231723
// change to dirty
1724-
if (this.$pristine) {
1725-
this.$dirty = true;
1726-
this.$pristine = false;
1724+
if (ctrl.$pristine) {
1725+
ctrl.$dirty = true;
1726+
ctrl.$pristine = false;
17271727
$animate.removeClass($element, PRISTINE_CLASS);
17281728
$animate.addClass($element, DIRTY_CLASS);
17291729
parentForm.$setDirty();
17301730
}
17311731

1732-
forEach(this.$parsers, function(fn) {
1732+
forEach(ctrl.$parsers, function(fn) {
17331733
value = fn(value);
17341734
});
17351735

1736-
if (this.$modelValue !== value) {
1737-
this.$modelValue = value;
1736+
if (ctrl.$modelValue !== value) {
1737+
ctrl.$modelValue = value;
17381738
ngModelSet($scope, value);
1739-
forEach(this.$viewChangeListeners, function(listener) {
1739+
forEach(ctrl.$viewChangeListeners, function(listener) {
17401740
try {
17411741
listener();
17421742
} catch(e) {
@@ -1772,17 +1772,17 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
17721772
* @param {string} trigger Event that triggered the update.
17731773
*/
17741774
this.$setViewValue = function(value, trigger) {
1775-
var debounceDelay = this.$options && (isObject(this.$options.debounce)
1776-
? (this.$options.debounce[trigger] || this.$options.debounce['default'] || 0)
1777-
: this.$options.debounce) || 0;
1775+
var debounceDelay = ctrl.$options && (isObject(ctrl.$options.debounce)
1776+
? (ctrl.$options.debounce[trigger] || ctrl.$options.debounce['default'] || 0)
1777+
: ctrl.$options.debounce) || 0;
17781778

17791779
$timeout.cancel(pendingDebounce);
17801780
if (debounceDelay) {
17811781
pendingDebounce = $timeout(function() {
17821782
ctrl.$$realSetViewValue(value);
17831783
}, debounceDelay);
17841784
} else {
1785-
this.$$realSetViewValue(value);
1785+
ctrl.$$realSetViewValue(value);
17861786
}
17871787
};
17881788

0 commit comments

Comments
 (0)