diff --git a/src/ng/directive/validators.js b/src/ng/directive/validators.js index 1c5872a15891..787a80a71ab7 100644 --- a/src/ng/directive/validators.js +++ b/src/ng/directive/validators.js @@ -69,7 +69,7 @@ var requiredDirective = ['$parse', function($parse) { link: function(scope, elm, attr, ctrl) { if (!ctrl) return; // For boolean attributes like required, presence means true - var value = 'required' in attr || $parse(attr.ngRequired)(scope); + var value = attr.hasOwnProperty('required') || $parse(attr.ngRequired)(scope); if (!attr.ngRequired) { // force truthy in case we are on non input element diff --git a/test/ng/directive/validatorsSpec.js b/test/ng/directive/validatorsSpec.js index ffd5d5aced0f..c7259c67c933 100644 --- a/test/ng/directive/validatorsSpec.js +++ b/test/ng/directive/validatorsSpec.js @@ -696,6 +696,13 @@ describe('validators', function() { })); + it('should override "required" when ng-required="false" is set', function() { + var inputElm = helper.compileInput(''); + + expect(inputElm).toBeValid(); + }); + + it('should validate only once after compilation when inside ngRepeat', function() { helper.compileInput( '
' +