Skip to content

Commit 53c437e

Browse files
committed
fix(ionRadio): fix ng-change being reported before model changes
Closes #1741 BREAKING CHANGE: ion-radio no longer has an isolate scope. This will break your radio only if you were relying upon the radio having an isolate scope: if you were referencing `$parent.value` as the ng-disabled attribute, for example. Change your code from this: <ion-radio ng-disabled="{{$parent.isDisabled}}"></ion-radio> To this: <ion-radio ng-disabled="{{isDisabled}}"></ion-radio>
1 parent 49a2956 commit 53c437e

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

js/angular/directive/radio.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,30 @@ IonicModule
2222
restrict: 'E',
2323
replace: true,
2424
require: '?ngModel',
25-
scope: {
26-
ngModel: '=?',
27-
ngValue: '=?',
28-
ngDisabled: '=?',
29-
ngChange: '&',
30-
icon: '@',
31-
name: '@'
32-
},
3325
transclude: true,
34-
template: '<label class="item item-radio">' +
35-
'<input type="radio" name="radio-group"' +
36-
' ng-model="ngModel" ng-value="getValue()" ng-change="ngChange()" ng-disabled="ngDisabled">' +
37-
'<div class="item-content disable-pointer-events" ng-transclude></div>' +
38-
'<i class="radio-icon disable-pointer-events icon ion-checkmark"></i>' +
39-
'</label>',
26+
template:
27+
'<label class="item item-radio">' +
28+
'<input type="radio" name="radio-group">' +
29+
'<div class="item-content disable-pointer-events" ng-transclude></div>' +
30+
'<i class="radio-icon disable-pointer-events icon ion-checkmark"></i>' +
31+
'</label>',
4032

4133
compile: function(element, attr) {
42-
if(attr.name) element.children().eq(0).attr('name', attr.name);
4334
if(attr.icon) element.children().eq(2).removeClass('ion-checkmark').addClass(attr.icon);
35+
var input = element.find('input');
36+
forEach({
37+
'name': attr.name,
38+
'value': attr.value,
39+
'disabled': attr.disabled,
40+
'ng-value': attr.ngValue,
41+
'ng-model': attr.ngModel,
42+
'ng-disabled': attr.ngDisabled,
43+
'ng-change': attr.ngChange
44+
}, function(value, name) {
45+
if (isDefined(value)) {
46+
input.attr(name, value);
47+
}
48+
});
4449

4550
return function(scope, element, attr) {
4651
scope.getValue = function() {

0 commit comments

Comments
 (0)