Skip to content

Commit d2c293d

Browse files
committed
Reducing n number of watchers for n number of input elements by merging two watchers.
1 parent d548357 commit d2c293d

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

dist/bootstrap-angular-validation.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/directives/validation.directive.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,10 @@ angular.module("bootstrap.angular.validation").directive("bsValidation", ["$inte
129129
}
130130
});
131131

132-
$scope.$watch($attr.ngModel, function() {
133-
displayOrHideError();
134-
});
135-
136132
// Look when user try to submit the form & display validation errors.
137-
$scope.$watch("formSubmissionAttempted", function() {
138-
displayOrHideError();
139-
});
133+
$scope.$watchCollection(function() {
134+
return $scope.formSubmissionAttempted && ngModelController.$error;
135+
}, displayOrHideError);
140136
}
141137
};
142138
}]);

0 commit comments

Comments
 (0)