mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
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>
This commit is contained in:
35
js/angular/directive/radio.js
vendored
35
js/angular/directive/radio.js
vendored
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user