Skip to content

Commit

Permalink
fix(ionRadio): fix ng-change being reported before model changes
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
perrygovier committed Aug 5, 2014
1 parent 49a2956 commit 53c437e
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions js/angular/directive/radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,30 @@ IonicModule
restrict: 'E',
replace: true,
require: '?ngModel',
scope: {
ngModel: '=?',
ngValue: '=?',
ngDisabled: '=?',
ngChange: '&',
icon: '@',
name: '@'
},
transclude: true,
template: '<label class="item item-radio">' +
'<input type="radio" name="radio-group"' +
' ng-model="ngModel" ng-value="getValue()" ng-change="ngChange()" ng-disabled="ngDisabled">' +
'<div class="item-content disable-pointer-events" ng-transclude></div>' +
'<i class="radio-icon disable-pointer-events icon ion-checkmark"></i>' +
'</label>',
template:
'<label class="item item-radio">' +
'<input type="radio" name="radio-group">' +
'<div class="item-content disable-pointer-events" ng-transclude></div>' +
'<i class="radio-icon disable-pointer-events icon ion-checkmark"></i>' +
'</label>',

compile: function(element, attr) {
if(attr.name) element.children().eq(0).attr('name', attr.name);
if(attr.icon) element.children().eq(2).removeClass('ion-checkmark').addClass(attr.icon);
var input = element.find('input');
forEach({
'name': attr.name,
'value': attr.value,
'disabled': attr.disabled,
'ng-value': attr.ngValue,
'ng-model': attr.ngModel,
'ng-disabled': attr.ngDisabled,
'ng-change': attr.ngChange
}, function(value, name) {
if (isDefined(value)) {
input.attr(name, value);
}
});

return function(scope, element, attr) {
scope.getValue = function() {
Expand Down

0 comments on commit 53c437e

Please sign in to comment.