From 53c437e2054e1f95d548e42b386f7a82aba56a14 Mon Sep 17 00:00:00 2001 From: Perry Govier Date: Tue, 5 Aug 2014 16:42:10 -0500 Subject: [PATCH] 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: To this: --- js/angular/directive/radio.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/js/angular/directive/radio.js b/js/angular/directive/radio.js index 292addbe66..ad10396d4b 100644 --- a/js/angular/directive/radio.js +++ b/js/angular/directive/radio.js @@ -22,25 +22,30 @@ IonicModule restrict: 'E', replace: true, require: '?ngModel', - scope: { - ngModel: '=?', - ngValue: '=?', - ngDisabled: '=?', - ngChange: '&', - icon: '@', - name: '@' - }, transclude: true, - template: '', + template: + '', 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() {