mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(ionCheckbox): make ng-checked and ng-change work
Closes #1349. Closes #1361 BREAKING CHANGE: ion-checkbox no longer has an isolate scope. This will break your checkbox only if you were relying upon the checkbox having an isolate scope: if you were referencing `$parent.value` as the ng-disabled attribute, for example. Change your code from this: ```html <ion-checkbox ng-disabled="{{$parent.isDisabled}}"></ion-checkbox> ``` To this: ```html <ion-checkbox ng-disabled="{{isDisabled}}"></ion-checkbox> ```
This commit is contained in:
@@ -28,13 +28,28 @@ describe('Ionic Checkbox', function() {
|
||||
});
|
||||
|
||||
it('should pass down attrs', function() {
|
||||
el = compile('<ion-checkbox ng-checked=1 ng-disabled=2 ng-true-value=3 ng-false-value=4>')(scope);
|
||||
el = compile('<ion-checkbox name="name" ng-model="model" ng-checked="checked" ng-disabled="disabled" ng-true-value="true-value" ng-false-value="false-value" ng-change="change">')(scope);
|
||||
scope.$apply();
|
||||
var input = el.find('input');
|
||||
expect(input.attr('ng-checked')).toBe('1');
|
||||
expect(input.attr('ng-disabled')).toBe('2');
|
||||
expect(input.attr('ng-true-value')).toBe('3');
|
||||
expect(input.attr('ng-false-value')).toBe('4');
|
||||
expect(input.attr('name')).toBe('name');
|
||||
expect(input.attr('ng-model')).toBe('model');
|
||||
expect(input.attr('ng-checked')).toBe('checked');
|
||||
expect(input.attr('ng-disabled')).toBe('disabled');
|
||||
expect(input.attr('ng-true-value')).toBe('true-value');
|
||||
expect(input.attr('ng-false-value')).toBe('false-value');
|
||||
expect(input.attr('ng-change')).toBe('change');
|
||||
});
|
||||
|
||||
it('shouhld ngChecked properly', function() {
|
||||
el = compile('<ion-checkbox ng-checked="shouldCheck">')(scope);
|
||||
scope.$apply();
|
||||
var input = el.find('input');
|
||||
expect(input[0].hasAttribute('checked')).toBe(false);
|
||||
scope.$apply('shouldCheck = true');
|
||||
expect(input[0].hasAttribute('checked')).toBe(true);
|
||||
scope.$apply('shouldCheck = false');
|
||||
expect(input[0].hasAttribute('checked')).toBe(false);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user