diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 27813a4686c0..a20d0b5fadb0 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -673,7 +673,7 @@ function checkboxInputType(scope, element, attr, ctrl) { // Override the standard `$isEmpty` because a value of `false` means empty in a checkbox. ctrl.$isEmpty = function(value) { - return value !== trueValue; + return value !== true; }; ctrl.$formatters.push(function(value) { diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index 668fa0b54a1e..ccf6697e8528 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -1111,6 +1111,37 @@ describe('input', function() { expect(inputElm[0].checked).toBe(false); expect(inputElm).toBeInvalid(); }); + + it('should allow custom enumaration even if it is required', function() { + compileInput(''); + + scope.$apply(function() { + scope.name = 'y'; + }); + expect(inputElm[0].checked).toBe(true); + expect(inputElm).toBeValid(); + + scope.$apply(function() { + scope.name = 'n'; + }); + expect(inputElm[0].checked).toBe(false); + expect(inputElm).toBeInvalid(); + + scope.$apply(function() { + scope.name = 'something else'; + }); + expect(inputElm[0].checked).toBe(false); + expect(inputElm).toBeInvalid(); + + browserTrigger(inputElm, 'click'); + expect(scope.name).toEqual('y'); + expect(inputElm).toBeValid(); + + browserTrigger(inputElm, 'click'); + expect(scope.name).toEqual('n'); + expect(inputElm).toBeInvalid(); + }); });