Skip to content

Commit d2e54a8

Browse files
keithdmooreajoslin
authored andcommitted
feat(ionCheckbox): allow ng-disabled attribute
Closes #939.
1 parent 9d79905 commit d2e54a8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Diff for: js/ext/angular/src/directive/ionicCheckbox.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ angular.module('ionic.ui.checkbox', [])
2727
ngModel: '=?',
2828
ngValue: '=?',
2929
ngChecked: '=?',
30+
ngDisabled: '=?',
3031
ngChange: '&'
3132
},
3233
transclude: true,
@@ -41,7 +42,8 @@ angular.module('ionic.ui.checkbox', [])
4142
compile: function(element, attr) {
4243
var input = element.find('input');
4344
if(attr.name) input.attr('name', attr.name);
44-
if(attr.ngChecked) input.attr('ng-checked', 'ngChecked');
45+
if(attr.ngChecked) input.attr('ng-checked', attr.ngChecked);
46+
if(attr.ngDisabled) input.attr('ng-disabled', attr.ngDisabled);
4547
if(attr.ngTrueValue) input.attr('ng-true-value', attr.ngTrueValue);
4648
if(attr.ngFalseValue) input.attr('ng-false-value', attr.ngFalseValue);
4749
}

Diff for: js/ext/angular/test/directive/ionicCheckbox.unit.js

+10
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,14 @@ describe('Ionic Checkbox', function() {
2727
expect(div.text()).toEqual('INNER TEXT');
2828
});
2929

30+
it('should pass down attrs', function() {
31+
el = compile('<ion-checkbox ng-checked=1 ng-disabled=2 ng-true-value=3 ng-false-value=4>')(scope);
32+
scope.$apply();
33+
var input = el.find('input');
34+
expect(input.attr('ng-checked')).toBe('1');
35+
expect(input.attr('ng-disabled')).toBe('2');
36+
expect(input.attr('ng-true-value')).toBe('3');
37+
expect(input.attr('ng-false-value')).toBe('4');
38+
});
39+
3040
});

0 commit comments

Comments
 (0)