diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index 2f78db049edd..5bac0c456f66 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -1229,11 +1229,11 @@ function checkboxInputType(scope, element, attr, ctrl) {
return value !== trueValue;
};
- ctrl.$formatters.push(function(value) {
+ ctrl.$formatters.unshift(function(value) {
return value === trueValue;
});
- ctrl.$parsers.push(function(value) {
+ ctrl.$parsers.unshift(function(value) {
return value ? trueValue : falseValue;
});
}
diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js
index eba3028e7bce..baeb2ff583d3 100644
--- a/test/ng/directive/inputSpec.js
+++ b/test/ng/directive/inputSpec.js
@@ -1822,6 +1822,33 @@ describe('input', function() {
});
+ it('should allow custom enumeration and ng-required', function() {
+ compileInput('');
+
+ scope.$apply(function() {
+ scope.name = 'y';
+ });
+ expect(inputElm[0].checked).toBe(true);
+
+ scope.$apply(function() {
+ scope.name = 'n';
+ });
+ expect(inputElm[0].checked).toBe(false);
+
+ scope.$apply(function() {
+ scope.name = 'something else';
+ });
+ expect(inputElm[0].checked).toBe(false);
+
+ browserTrigger(inputElm, 'click');
+ expect(scope.name).toEqual('y');
+
+ browserTrigger(inputElm, 'click');
+ expect(scope.name).toBeUndefined();
+ });
+
+
it('should be required if false', function() {
compileInput('');