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:
Andrew Joslin
2014-05-13 07:09:01 -06:00
parent 07da4ced2e
commit a006d89612
3 changed files with 41 additions and 20 deletions

View File

@@ -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);
});
});